Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Facebook event for specific page with FB Graph API

I need synchronize events from my CMS to Facebook specific page. I'm trying to create an event for my created page but still have no result. I can simply create events, related to user, but not to page. Code uses Facebook PHP-SDK.

$page_id = '31337';
$page = $facebook->api("/{$page_id}");
$event_data = array(
    'name'          => 'Event: ' . date("H:m:s"),
    'start_time'    => time() + 60*60,
    'end_time'      => time() + 60*60*2,
    'owner'         => $page
);
$post = $facebook->api("/{$page_id}/events", 'POST', $event_data);

After executing this snippet, event is created but as I've said before it belongs to user though 'owner' in given data is page. My app has manage_pages, create_event and publish_stream permissions. What I'm missing?

Solution

At "OLD REST API" documentation I have found that "new Graph API" still needs parameter page_id. So variable $event_data should be like below:

$event_data = array(
    'name'          => 'Event: ' . date("H:m:s"),
    'start_time'    => time() + 60*60,
    'end_time'      => time() + 60*60*2,
    'page_id'       => $page['id]
);
like image 754
Pawka Avatar asked Oct 11 '10 13:10

Pawka


People also ask

Can you create an event from a Facebook page?

Tap your Page, then tap Events. Tap Create Event, then tap Online or In Person. Add the event details, then tap Create Event.

Is Facebook Graph API deprecated?

Applies to all versions. Facebook Analytics will no longer be available after June 30, 2021. Additionally, we are deprecating the App Dashboard Plugin for Marketing API. For more information visit the Business Help Center.

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.


2 Answers

«Creates an event on behalf of the user if the application has an active session key for that user; otherwise it creates an event on behalf of the application.» — Source

Does this answer your question?

like image 60
Julio Santos Avatar answered Sep 21 '22 23:09

Julio Santos


You need to pass the access token of the managed page, which you can get from graph.facebook.com/me/account (of course passing your access token to get the list of fan pages you manace). You will see there a list of access tokens for each of your fan pages, use those to create events or post to your fanpage.

like image 24
Matias Paterlini Avatar answered Sep 19 '22 23:09

Matias Paterlini