I know this question has been ask serveral times but i'm not able to find a solution from the other posts:
My goal is to read a facebook feed from one of mine facebook sites! On that site there are several posts with multiple photos.
In the first call you see down, I always get only one photo, but i need all of them. For that i make the secound Request which should deliver me all details for that post if i use v2.1 which i have changend in FacebookRequest.php
Here my code:
FacebookSession::setDefaultApplication('yyy','xxxxx');
$session = new FacebookSession('yyy|xxxxx');
$url = '/{pageid}/feed';
$request = new FacebookRequest($session, 'GET', $url);
$response = $request->execute();
graphObject = $response->getGraphObject();
$rawFeed = $graphObject->asArray();
foreach($rawFeed['data'] as $item) {
$x = explode('_',$item->id);
$url = "/".$x[0];
$request = new FacebookRequest($session, 'GET', $url);
$response = $request->execute();
$graphObject = $response->getGraphObject();
$object = $graphObject->asArray();
echo "<pre>";var_dump($object);echo "<pre>";
}
If i use this code i always get the error:
Fatal error: Uncaught exception 'Facebook\FacebookAuthorizationException' with message '(#100) Requires user session'
Why does the first request returns back the data and the scound one runs into this exception!
Edit 1
Found a solution for the session problem(Facebook Access Token for Pages) - ( top answer ) but still stuck at the photo problem:
Now i get back the data from Facebook, but i don't get the photos attached to the post!
Here the way i get no authentication problem anymore
$accessToken = "{accestToken from GRAPH API EXPLORER}";
$session = new FacebookSession($accessToken);
$url = "/{myPersonalFB-ID}/accounts";
$request = new FacebookRequest($session, 'GET', $url);
$response = $request->execute();
$graphObject = $response->getGraphObject();
$pages = $graphObject->asArray();
$pageAccesstoken = false;
foreach($pages['data'] as $page)
{
if($page->id != "{MyPageID}") continue;
else {
$pageAccesstoken = $page->access_token;
}
}
$session = new FacebookSession($pageAccesstoken);
$url = '/{MyPageID}/feed';
...
...