Is it possible to programmatically add an event to a page using Facebook Graph API? If yes, what HTTP request shall be made?
For example, Startup Weekend has events on its Facebook page. These events can be added using Graph API Event object?
UPDATE
Creating event with the API is no longer possible in v2.0+. Check: https://developers.facebook.com/docs/apps/changelog#v2_0
Yes it's possible.
Permissions:
create_event
manage_pages
So first you get the page id and its access token, through:
$facebook->api("/me/accounts");
The Result will be something like:
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
)
)
)
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");
The access token, if successful call, should be accessible: $page_info['access_token']
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! :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With