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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大