Issue
From here: https://developers.facebook.com/docs/graph-api/reference/user/accounts/ I got to write this in my code
$request = new FacebookRequest(
$session,
'GET',
'/{user-id}/accounts'
);
$response = $request->execute();
The problem here is with version 2.8 of the API and SDK 5.0 execute() doesn't exist. How can I get a list of all the pages on a Facebook account.
Solution
@JayNCoke was correct with the approach.
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.5',
]);
// Sets the default fallback access token so we don't have to pass it to each request
$fb->setDefaultAccessToken('{access-token}');
$response = $fb->get('{user-id}/accounts');
$response returns a Facebook\FacebookResponse object
To get it in a usable data format, just call getDecodedBody() like below
$response = $response->getDecodedBody();
This returns an array.
Answered By - Oladipo
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.