得到facebook评论返回错误

时间:2015-02-26 12:23:51

标签: facebook facebook-graph-api review

我首先使用facebook api获取页面令牌

function createSession($app_id,$app_secret){
    FacebookSession::setDefaultApplication(
    $app_id,$app_secret
    );
    $testUserPermissions = array('user_actions.books','user_actions.fitness','user_actions.music','user_actions.news','user_actions.video','user_birthday','user_games_activity','user_groups','user_hometown','user_interests','user_location','user_relationship_details','user_religion_politics','user_tagged_places','user_videos','user_work_history','read_friendlists','read_page_mailboxes','manage_notifications','read_mailbox','publish_actions','read_stream', 'user_photos','manage_pages','public_profile','user_friends','email','user_about_me','user_activities','user_education_history','user_events','user_likes','user_relationships','user_status','user_website','read_insights','rsvp_event');
    $testUserPath = '/' . $app_id . '/accounts/test-users';
    #$testUserPath = '/100008488695640/accounts/test-users';
    $params = array(
    'installed' => true,
    'name' => 'User test',
    'locale' => 'zh_TW',
    'permissions' => implode(',', $testUserPermissions),
    );
    echo var_dump($params);
    $request = new FacebookRequest(new FacebookSession($app_id . '|' .$app_secret), 'POST', $testUserPath, $params);

    $response = $request->execute()->getGraphObject();
    echo var_dump($response);
    #$testUserId = $response->getProperty('id');
    $testUserAccessToken = $response->getProperty('access_token');
    return new FacebookSession($testUserAccessToken);

}

这是我的获取令牌

然后我用这个标记来获得评论

https://graph.facebook.com/v2.2/185342243407/ratings?field=open_graph_story&access_token= $ token_value

但它返回

{    “错误”:{       “message”:“(#210)此调用需要页面访问令牌。”,       “type”:“OAuthException”,       “代码”:210    } }

我如何获得页面令牌?

没有使用令牌?

2 个答案:

答案 0 :(得分:0)

确保您真正使用页面令牌。将令牌放入调试器中,看看它是否是页面令牌:https://developers.facebook.com/tools/debug/

有关令牌的更多信息:

答案 1 :(得分:0)

当您请求多个权限时,其中一些权限可能与您正在调用的端点一起使用,而其中一些可能不会,导致此210错误。

就我而言,向profile_pic添加/me?fields=id,first_name,last_name,email权限会导致此错误。