How to create an event on Fan pages and for Groups using the Facebook JavaScript SDK
I am able to create an event using the Facebook JavaScript SDK. Now I want to create an e开发者_如何学Govent as the fan page creator. How can I do this? And how do I create an event for groups?
I am using the following code to create events:
FB.api('/me/events', 'post', {
name: "title",
start_time: "start time",
end_time: "end time",
description: "description",
location: "location"
}, function (resp) {
});
As explained in Graph API > PAGE doc :
To perform the operation as a Page, and not the current user, you must use the Page's access token, not the user access token commonly used for reading Graph API objects. This access token can be retrieved by issuing an HTTP GET to /USER_ID/accounts with the manage_pages permission. This will return a list of Pages (including application profile Pages) to which the user has administrative access, along with access_tokens for those Pages.
Then, using the Page access token :
You can create an event for a page by issuing an HTTP POST request to PAGE_ID/events with the create_event and manage_pages permissions.
精彩评论