Facebook活动API [英] Facebook events API

查看:58
本文介绍了Facebook活动API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Facebook上有一个页面,并在上面创建了许多事件.

我还在移动应用中使用这些事件.

但是现在图形API显示了我已经去过的事件.

如果您访问图形API资源管理器,则您会看到它显示了4个事件.

但是从底部开始的最后2个事件是过去的事件.

我已经为他们添加了结束日期,所以这里不是问题.

该怎么做以使图形API不会显示这两个事件?

我不想将它们从Facebook中删除,而只是想将其隐藏.

请咨询.

解决方案

您可以使用since查询参数(它接受unix时间戳)将facebook返回的数据限制为仅显示在特定日期之后创建的事件. >

因此,如果您想要在2012年10月8日之后或其他任何日期创建的事件,则可以使用since查询参数进行调用,在这种情况下,unix时间戳为将为1349654400.

现在,如果我们使用since查询参数和上述unix时间戳进行调用,它将返回2012年10月8日之后创建的所有事件.

这是在since查询参数的资源管理器.

如果以上链接不起作用:

https://developers.facebook. com/tools/explorer?method = GET& path = jarnvags%2Fevents%3Fsince%3D1349654400

路径:jarnvags/events?since = 1349654400

让我知道这是否对您有所帮助:)

这是使用 FQL文档 ="https://developers.facebook.com/docs/reference/fql/event/" rel ="nofollow"> https://developers.facebook.com/docs/reference/fql/event/

只是想强调由 cpilko (下面的注释中的注释),以便将来看到此答案的人们可以轻松地注意到它,您不必再将日期转换为时间戳,它也只适用于日期(2012-10-08).

这是从Facebook事件文档中引用的 Events Timezone Migration Note :

事件时区迁移说明

从事件时区"迁移开始,所有事件时间均为 始终为ISO-8601格式的字符串; 'date_format'查询字符串 修饰符不再具有任何作用.现在有以下格式 返回,具体取决于事件的类型:

仅日期(例如,"2012-07-04"):具有日期但没有日期的事件 具体时间呢.精确时间(例如,"2012-07-04T19:00:00-0700"): 在特定时间点以特定偏移量开始的事件 来自UTC.这是新的Facebook事件跟踪时间的方式,并且 允许用户查看不同时区的事件.当地时间 (不建议使用,例如"2012-07-04T19:00:00"):不会 有任何时区信息.不建议使用此格式,但是 由于仍然存在旧事件,因此继续返回 系统.

I have a page on facebook and i have created a number of events on it.

I also use those events in my mobile app.

But now the graph API shows events that i have already been to.

If you go to Graph API Explorer you'll see it shows 4 events.

But the last 2 events from the bottom are the past events.

I have already added end date for them so that can't be the issue here.

What to do so that the graph API doesn't show those 2 events?

I don't want to remove them from facebook, but just want to hide it.

Please advice.

解决方案

You can restrict the data returned by facebook to show only the events created after a specific date using the since query parameter which accepts a unix timestamp.

So if you want events which are created after 8th of October 2012 or any other date, you can make a call with the since query parameter, In this case the unix timestamp of 08 Oct 2012 00:00:00 GMT will be 1349654400.

Now if we make a call with the since query parameter and the above unix timestamp, It'll return all the events created after 8th of October 2012.

Here's a working call made on Graph API Explorer with the since query parameter.

In case if the above link does not work:

https://developers.facebook.com/tools/explorer?method=GET&path=jarnvags%2Fevents%3Fsince%3D1349654400

Path: jarnvags/events?since=1349654400

Let me know if this helped you :)

EDIT: Here's how to do it with FQL:

SELECT eid, name, description, pic_big, start_time, end_time, location FROM event WHERE creator = 109341359096369 AND eid IN (SELECT eid FROM event_member WHERE uid = 109341359096369) AND start_time >= now() ORDER BY start_time

And here's how you should do it in PHP:

$pageID = '109341359096369';
$fql = 'SELECT eid, name, description, pic_big, start_time, end_time, location FROM event WHERE creator = ' . $pageID . ' AND eid IN (SELECT eid FROM event_member WHERE uid = ' . $pageID . ') AND start_time >= now() ORDER BY start_time';
$ret_obj = $facebook->api(array(
                           'method' => 'fql.query',
                           'query' => $fql,
                         ));
print_r($ret_obj);

Check out event table FQL docs at: https://developers.facebook.com/docs/reference/fql/event/

EDIT 2: Just wanted to highlight the point made by cpilko below in comments so people who see this answer in future could easily notice it, You don't have to convert the date to timestamp anymore, It works with just the date as well (2012-10-08).

And here's the Events Timezone Migration Note quoted from facebook events doc:

Events Timezone Migration Note

Starting with the 'Events Timezone' migration, all event times are always ISO-8601 formatted strings; the 'date_format' query string modifier no longer has any effect. The following formats are now returned, depending on the type of event:

Date-only (e.g., '2012-07-04'): events that have a date but no specific time yet. Precise-time (e.g., '2012-07-04T19:00:00-0700'): events that start at a particular point in time, in a specific offset from UTC. This is the way new Facebook events keep track of time, and allows users to view events in different timezones. Local-time (deprecated, e.g., '2012-07-04T19:00:00'): legacy events that do not have any timezone information. This format is deprecated, but continues to be returned due to legacy events that are still in the system.

这篇关于Facebook活动API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆