heroku - facebook graph API does not return event -
i trying use graph api call return events of user logged in app. , $event null time although have created bunch of events myself, help?
here code login event api call:
require_once('appinfo.php'); // enforce https on production if (substr(appinfo::geturl(), 0, 8) != 'https://' && $_server['remote_addr'] != '127.0.0.1') { header('location: https://'. $_server['http_host'] . $_server['request_uri']); exit(); } // provides access helper functions defined in 'utils.php' require_once('utils.php'); require_once('sdk/src/facebook.php'); $facebook = new facebook(array( 'appid' => appinfo::appid(), 'secret' => appinfo::appsecret(), 'sharedsession' => true, 'trustforwarded' => true, )); $user_id = $facebook->getuser(); if ($user_id) { try { // fetch viewer's basic information $basic = $facebook->api('/me'); } catch (facebookapiexception $e) { // if call fails check if still have user. user // cleared if error because of invalid accesstoken if (!$facebook->getuser()) { header('location: '. appinfo::geturl($_server['request_uri'])); exit(); } } // fetches things . 'limit=*" returns * values. // see format of data retrieving, use "graph api // explorer" @ https://developers.facebook.com/tools/explorer/ $likes = idx($facebook->api('/me/likes?limit=4'), 'data', array()); // fetches 4 of friends. $friends = idx($facebook->api('/me/friends?limit=4'), 'data', array()); // , returns 16 of photos. $photos = idx($facebook->api('/me/photos?limit=16'), 'data', array()); // fetch event information // $events = idx($facebook->api('/me/events?limit=5'), 'data', array()); $events = $facebook->api('/me/events','get'); print("11111"); if($events == null) print("empty");
i see no login code in example, sure user logged in? see php sdk "usage": https://github.com/facebook/facebook-php-sdk
anyway, tried in 1 of projects, user events same call need permission "user_events":
$facebook->getloginurl(array('scope' => 'user_events'));
Comments
Post a Comment