【问题标题】:Retrieve full user profile using facebook oauth token使用 facebook oauth 令牌检索完整的用户个人资料
【发布时间】:2016-10-19 19:01:08
【问题描述】:

我正在使用 facebook SDK for oauth 构建一个 android 应用程序。我有一个访问令牌和用户 ID。

当我使用该令牌和用户 ID 发出 http 请求时,我得到了这个 json:

{
  "name": "Robel Alemu",
  "id": "994449194002838"
}

但既然该令牌对public_profileuser_friends 都具有权限,为什么我只得到名称和ID?

这是我的代码:

new GraphRequest(
  AccessToken.getCurrentAccessToken(),
                loginResult.getAccessToken().getUserId(),
        null,
        httpMethod.GET,
        new GraphRequest.Callback() {
            public void onCompleted(GraphResponse response) {                
                Toast.makeText(getApplicationContext(),response.toString(),Toast.LENGTH_SHORT).show();
                /* handle the result */
            }
        }
).executeAsync();

这是我调试得到的令牌图片

【问题讨论】:

  • 你需要在请求中指定你想要的字段

标签: android facebook facebook-graph-api oauth


【解决方案1】:

您需要添加字段参数,例如

$ fbapi '/v2.6/me?fields=first_name,relationship_status,gender,locale'
{
  "first_name": "Yuri",
  "gender": "male",
  "locale": "en_US",
  "id": "999999999999"
}

【讨论】:

    猜你喜欢
    • 2015-05-03
    • 2014-10-03
    • 1970-01-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多