views:

144

answers:

2

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]
);
+2  A: 

«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?

Júlio Santos
Thx for answer, but actually not. When user is not logged in, event is created at the app's page. But not at specific page, which id I have.
Pawka
But in your given link I have found the solution: "The page_id argument can be used to generate events for groups and Pages.". Its strange that "new graph API" documentation lacks info about page_id parameter which is described at "Old REST API".
Pawka
Great then :) Facebook's documentation is far from decent, as you probably know by now...
Júlio Santos