php - Facebook OpenGraph GraphObject is returning empty object -
i'm trying read ratings facebook page display externally, using php sdk. have long live access token, , have been able use pull in main page data, when try access /ratings
endpoint, receive empty array ( )
class facebookreviews { protected $session; protected $page; protected $ratings; protected $appid; protected $appsecret; function __construct($appid = null, $appsecret = null) { session_start(); $this->appid = '123456789123456'; $this->appsecret = '1234567890abcdefghijklmnopqrstuv'; facebook\facebooksession::setdefaultapplication($this->appid, $this->appsecret); $this->session = new facebook\facebooksession('long live access token generated on graph api'); try { $this->session->validate(); } catch (facebook\facebookrequestexception $ex) { // session not valid, graph api returned exception reason. echo $ex->getmessage(); } catch (\exception $ex) { // graph api returned info, may mismatch current app or have expired. echo $ex->getmessage(); } try { $this->page = (new facebook\facebookrequest($this->session, 'get', '/123456789123456/ratings'))->execute()->getgraphobject()->asarray(); } catch(facebook\facebookrequestexception $e) { echo "exception occured, code: " . $e->getcode(); echo " message: " . $e->getmessage(); } } public function result() { return $this->page; } } $reviews = new facebookreviews(); print_r($reviews->result());
if remove /ratings
request uri, returns data fine, mentioned in there doesn't work.
i generated long live access token own account, has admin access page