Graph API: 2.4
PHP SDK: "facebook/php-sdk-v4": "~5.0"
I'd like to get details about a page via PHP and the PHP SDK. Using the query:
$response = $fb->get('/' . $sPageID . '?fields=posts', $_SESSION['facebook_access_token']);
returns the posts with a good amount of data. But unfortunately wrong values:
The limit 25 for likes for instance applies here. So even if one post should have 150 likes, if I do an count ($post['likes'])
I only get 25 as a result.
So I tried to change my query and according to the Graph Explorer
this seems to be working fine:
PAGE_ID/posts?fields=likes.limit(100),message,comments,shares,picture,link,type
Now I can't get this transformed into my PHP call. I receive timeouts and
Fatal error: Uncaught exception 'Facebook\Exceptions\FacebookSDKException' with message 'Unable to convert response from Graph to a GraphNode because the response looks like a GraphEdge. Try using GraphNodeFactory::makeGraphEdge() instead.' in ...
Is this possible with one query in PHP or do I have to run multiple queries, one for each post?
I found this answer, and if because the end of point of this request is a GraphEdge, so try this:
// Get basic info on the user from Facebook.
try {
$response = $fb->get('/' . $sPageID . '?fields=posts', $_SESSION['facebook_access_token']);
} catch (Facebook\Exceptions\FacebookSDKException $e) {
dd($e->getMessage());
}
$getGraphEdge = $response->getGraphEdge();
I hope this help you.
Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With