doujiaozhao2489 2014-09-02 18:14
浏览 11

/v2.1/{post-id}不提供照片

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';
...
...
  • 写回答

2条回答 默认 最新

  • dongzhansong5785 2014-09-02 20:12
    关注

    If you require an app session, use the following instead:

    $session = FacebookSession::newAppSession();
    

    You can then pass this app session into your API call to retrieve the page feed.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度