dov11020 2015-06-08 13:51
浏览 38
已采纳

如何从其他用户获取访问令牌

I need to read the posts on facebook. I had create the application and the program works if I log with my credential. But when I log with another credential ( like another profile that I have just created) the program doesn't work anymore. This is my login page:

$config = array(
        'appId' => APPID,
        'secret' => APPSECRET,
        'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
);

$facebook = new Facebook($config);
$user_id = $facebook->getUser();

if(!empty($_SESSION)) {

if($user_id) {


    try {

        $user_profile = $facebook->api('/me','GET');




        $login_url = $facebook->getLoginUrl(array('scope' => 'user_posts'));
        $access_token=$facebook->getAccessToken();
        $facebook->setAccessToken($access_token);

    } catch(FacebookApiException $e) {


        error_log($e->getType());
        error_log($e->getMessage());
    }
}
} else {



    $login_url = $facebook->getLoginUrl(array('scope' => 'user_posts'));

    header("Location: ".$login_url);

}

when I login I obtain the access token and I call graph api:

https://graph.facebook.com/******/posts?access_token=**

This is operation work if I m who is logged in the application. If another login in the app this is not work. Maybe it's a authentication problem. Maybe I forget some operation that I must do to authentica with another account. Anyone can help me?

  • 写回答

3条回答 默认 最新

  • douban5644 2015-06-09 05:27
    关注

    You need to submit your App to Facebook then Facebook will check and pass you app then you can access you app other account. If you want to check App Functionality you can use Facebook App test user Id. Below I have Explained how to get test user

    1. Goto App Page.
    2. Click on Roles.
    3. Click on to Right Corner Test users.
    4. It will show your test user details.
    5. Use this details and access you App.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探