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条)

报告相同问题?