Reputation: 3251
I'm trying to access an element inside a Facebook API response. The response is a Facebook Graph Object which when outputted to the screen is shown below.
// send request
$response = (new FacebookRequest($session, 'GET', '/me/inbox?limit=0'))->execute();
// get Facebook Graph Object
$object = $response->getGraphObject();
echo print_r($object);
//Output from print_r
Facebook\GraphObject Object (
[backingData:protected] => Array (
[data] => Array ( ) [summary] => stdClass Object (
[unseen_count] => 0 [unread_count] => 6 [updated_time] => 2014-11-09T13:41:26+0000 )
)
)
I'm trying to access 'unread_count' inside the array however having no luck. Could someone also explain what it is as its not your typical array and includes objects.
Upvotes: 0
Views: 739
Reputation: 73984
Try this:
$object = $response->getGraphObject()->asArray();
echo var_dump($object);
Source: https://developers.facebook.com/docs/php/GraphObject/4.0.0
Btw, keep in mind that you will not get read_mailbox
approved for platforms with a Facebook client:
This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available. For example, Android and iOS apps will not be approved for this permission. In addition, Web, Desktop and TV apps will not be granted this permission.
Source: https://developers.facebook.com/docs/facebook-login/permissions/v2.2
Upvotes: 1
Reputation: 1
You can try print_r(get_class_methods($object)). This will return all methods associated with the object.
Upvotes: 0