Facebook Android SDK 4.0:newGraphPathRequest返回“必须使用活动访问令牌来查询有关当前用户的信息。”

Can Poyrazoglu

我已经升级到Facebook Android SDK 4.0。我正在尝试请求图形路径:

AccessToken token = AccessToken.getCurrentAccessToken();
GraphRequest req = GraphRequest.newGraphPathRequest(token, 
    "me?fields=name,picture.width(400).height(400)",
    new GraphRequest.Callback() { ... });

我已遍历代码,并确认这token是一个完全有效的访问令牌,已在Graph API Explorer中对其进行了复制和调试,并且它是有效的。我还尝试me?fields=name,picture.width(400).height(400)使用相同的令牌通过将其复制粘贴到Graph API Explorer中来请求完全相同的路径,并且它可以工作。

但是,当我执行请求时:

req.executeAsync();

我在完成处理程序中收到此错误:

{"error":{"type":"OAuthException","message":"An active access token must be 
used to query information about the current user.","code":2500}}

我究竟做错了什么?

Can Poyrazoglu

找出问题所在。我将查询字符串参数更改为捆绑参数,并将其从URL中删除。有效。在我真正习惯的iOS SDK中,没有这样的问题。无论如何。解决方法如下:

  • 从网址中删除参数: GraphRequest req = GraphRequest.newGraphPathRequest(token, "me" ...);

  • 将它们作为捆绑添加。

例:

Bundle parameters = new Bundle();
parameters.putString("fields", "name,picture.width(400).height(400)");
req.setParameters(parameters);

有效。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章