如何使用Graph API以编程方式向页面添加事件? [英] How to programmatically add an event to a page using Graph API?
问题描述
可以使用Facebook Graph API以编程方式向页面添加事件吗?
如果是,应该提出什么HTTP请求?
Is it possible to programmatically add an event to a page using Facebook Graph API? If yes, what HTTP request shall be made?
例如,启动周末有其Facebook页面上的事件。
可以使用图形API事件对象添加这些事件?
For example, Startup Weekend has events on its Facebook page. These events can be added using Graph API Event object?
推荐答案
更新
v2.0 +中的API不再可能。检查: https://developers.facebook.com/docs/apps/changelog#v2_0
Creating event with the API is no longer possible in v2.0+. Check: https://developers.facebook.com/docs/apps/changelog#v2_0
是的,可以。
权限:
-
create_event
-
manage_pages
create_event
manage_pages
首先,您获取页面ID及其访问权限令牌,通过:
So first you get the page id and its access token, through:
$facebook->api("/me/accounts");
结果将如下:
Array
(
[data] => Array
(
[0] => Array
(
[name] => Page Name
[category] => Website
[id] => XXXXXX
[access_token] => XXXXX
)
[1] => Array
(
[name] => Page Name 2
[category] => Company
[id] => XXXXXXX
[access_token] => XXXXXXXX
)
)
)
更新:要检索该页面的 access_token
,您现在可以调用页面
对象直接像:
UPDATE: To retrieve the page's access_token
you could now call the page
object directly like:
$page_info = $facebook->api("/PAGE_ID?fields=access_token");
如果成功通话,访问令牌应该可以访问: $ page_info [ 'access_token']
The access token, if successful call, should be accessible: $page_info['access_token']
现在,您获得页面ID和访问令牌,并使用事件
连接:
Now you get the Page ID and access token and use the events
connection:
$nextWeek = time() + (7 * 24 * 60 * 60);
$event_param = array(
"access_token" => "XXXXXXXX",
"name" => "My Page Event",
"start_time" => $nextWeek,
"location" => "Beirut"
);
$event_id = $facebook->api("/PAGE_ID/events", "POST", $event_param);
你完成了! : - )
And you are done! :-)
这篇关于如何使用Graph API以编程方式向页面添加事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!