Search code examples
phpfacebookfacebook-php-sdkfacebook-events

Facebook php sdk v.3.2.3 - event create suddenly stopped working


Over one month ago I created FB app for site, which was able to create user events. It uses FB PHP SDK v.3.2.3 with Graph API version 1.0:

$facebook = new Facebook(array('appId' => MYAPPID, 'secret' => MYAPPSECRET));
$facebook->api('/me/events', 'POST', array('name' => 'Your meeting', 'start_time' => '2014-06-20', 'location' => 'Cool place', 'privacy_type' => 'SECRET'));

About few days ago it suddenly stopped working - now facebook returns OAuthException: "An unknown error has occurred.". I use valid token (checked).

I checked FB Devs blog but nothing there about it (often case, sadly). Any clues?


Solution

  • I was getting an error as well, and it was due to 'privacy_type' => 'SECRET' and time formats ... It looks like sending privacy_type => SECRET will throw an OAuth error, but still actually create an event with the correct permissions. ALSO, your dates need to be in ISO-8601 time format.

    https://developers.facebook.com/blog/post/2012/08/01/platform-migration--events-timezone-support/

    The reason privacy_type => SECRET will return an error, is that your app has permissions to create the event on the user's behalf, but once it is created, and set to private, the app doesn't have the necessary permissions to VIEW the event, and therefore can't return the event ID as a response.

    I would try checking my time formats, and then just removing privacy_type and see what happens.

    UPDATE: I also determined that you can set privacy_type to SECRET if you app also has user_events permissions. Just FYI.