Facebook FQL 错误

发布于 2024-12-06 11:07:34 字数 718 浏览 4 评论 0原文

SELECT eid, start_time, name FROM event WHERE (eid IN (SELECT eid FROM event_member WHERE (uid = me() AND start_time < 1317006752)))

此 FQL 查询应该返回 1317006752 之前开始的事件,

但是,除此之外,它还返回有效事件。

{
    "eid": 239526399426862,
    "start_time": 1317448800,
    "name": "Nick Grimshaw, The 2 Bears, S.C.U.M. & more! Friday 30th Sept, Only £4.50"
  }

如果我错了,请纠正我,但 1317448800 更大比1317006752

您可以通过转到活动页面并点击某个内容来验证这一点(即不参加),然后在此处运行查询

SELECT eid, start_time, name FROM event WHERE (eid IN (SELECT eid FROM event_member WHERE (uid = me() AND start_time < 1317006752)))

This FQL query is supposed to return events that began before 1317006752

However, it returns valid events IN ADDITION to this one

{
    "eid": 239526399426862,
    "start_time": 1317448800,
    "name": "Nick Grimshaw, The 2 Bears, S.C.U.M. & more! Friday 30th Sept, Only £4.50"
  }

Now correct me if I'm wrong, but 1317448800 is bigger than 1317006752.

You might be able to verify this by going to the event page, click on something (i.e not attend), then run the query here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离线来电— 2024-12-13 11:07:34

我认为您的问题可能是事件创建者和活动用户之间的时区差异。 Facebook 提供此通知:

注意start_time和end_time是输入的时间
由事件创建者。 Facebook 活动没有时区的概念,因此,
一般来说,您不应该将返回的值视为发生
在任何特定的绝对时间。当事件显示在
facebook,没有指定或暗示时区。

I think your issue might be the difference in timezone between the event creator and the active user. Facebook provides this notice:

Note that the start_time and end_time are the times that were inputted
by the event creator. Facebook Events have no concept of timezone, so,
in general, you can should not treat the value returned as occurring
at any particular absolute time. When an event is displayed on
facebook, no timezone is specified or implied.

执手闯天涯 2024-12-13 11:07:34

显然,event_member 中的 start_time 纯粹用于加速对 event_member 表的查询,该表可以返回许多结果。当事件的 start_time 更新时,它似乎没有更新。您的查询应该类似于以下内容才能正常工作,请注意差异:

SELECT eid, start_time, name
  FROM event 
 WHERE eid IN (SELECT eid 
                 FROM event_member 
                WHERE uid = me() AND start_time < 1317006752)
   AND start_time < 1317006752  

但我同意这是一个错误。

Apparently start_time in event_member is used purely to speed up queries on event_member table which can return many results. Seems like it is not updated when the event's start_time is updated. Your query should be like the following to work properly, note the difference:

SELECT eid, start_time, name
  FROM event 
 WHERE eid IN (SELECT eid 
                 FROM event_member 
                WHERE uid = me() AND start_time < 1317006752)
   AND start_time < 1317006752  

I agree this is a bug though.

星星的轨迹 2024-12-13 11:07:34

我今天在获取即将举行的活动时遇到了这个问题:
正确的 FQL 应该是

SELECT eid,name,description,location,start_time,end_time,pic_big FROM event WHERE eid IN (SELECT eid FROM event_member WHERE start_time>=PLACE_UNIX_TIMESTAMP AND uid=PLACE_UID_HERE) ORDER BY start_time ASC

编辑

获取此查询的结果是通过以下方式完成的:

$sql = '/fql?q=SELECT+eid,name,description,location,start_time,end_time,pic_big+FROM+event+WHERE+eid+IN+(SELECT+eid+FROM+event_member+WHERE+start_time>={time}+AND+uid={id})+ORDER+BY+start_time+ASC';
$fql_query_result = file_get_contents('https://graph.facebook.com/' . $sql '&access_token={token}');
$data = json_decode($fql_query_result,true, 512, JSON_BIGINT_AS_STRING));

重要的是,将 JSON_BIGINT_AS_STRING 选项添加到 json_decode 以防止 eid 成为缩短的浮点表示形式

编辑 2:
由于 const JSON_BIG... 仅可从 php5.4.X+ 获取:

if (defined('JON_BIGINT_AS_STRING')) return json_decode($fql_query_result,true, 512, JSON_BIGINT_AS_STRING);
return json_decode(preg_replace('/([^\\\])":([0-9]{10,})(,|})/', '$1":"$2"$3', $fql_query_result),true);

来源: http://www.pixelastic.com/blog/321:fix-floating-issue-json-decode-php-5-3

I had this problem today getting upcoming events :
The correct FQL should be

SELECT eid,name,description,location,start_time,end_time,pic_big FROM event WHERE eid IN (SELECT eid FROM event_member WHERE start_time>=PLACE_UNIX_TIMESTAMP AND uid=PLACE_UID_HERE) ORDER BY start_time ASC

EDIT

Fetching the result of this query is done by :

$sql = '/fql?q=SELECT+eid,name,description,location,start_time,end_time,pic_big+FROM+event+WHERE+eid+IN+(SELECT+eid+FROM+event_member+WHERE+start_time>={time}+AND+uid={id})+ORDER+BY+start_time+ASC';
$fql_query_result = file_get_contents('https://graph.facebook.com/' . $sql '&access_token={token}');
$data = json_decode($fql_query_result,true, 512, JSON_BIGINT_AS_STRING));

Important to add the JSON_BIGINT_AS_STRING option to the json_decode to prevent the eid of becoming a shortend float representation

EDIT 2:
As the const JSON_BIG... is only available from php5.4.X+ :

if (defined('JON_BIGINT_AS_STRING')) return json_decode($fql_query_result,true, 512, JSON_BIGINT_AS_STRING);
return json_decode(preg_replace('/([^\\\])":([0-9]{10,})(,|})/', '$1":"$2"$3', $fql_query_result),true);

source : http://www.pixelastic.com/blog/321:fix-floating-issue-json-decode-php-5-3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文