Android 安卓:Facebook社交环境API-交朋友

Android 安卓:Facebook社交环境API-交朋友,android,facebook,facebook-graph-api,Android,Facebook,Facebook Graph Api,我试图通过使用Facebook社交上下文API从以下文档中获取共同好友数和数据用户id和姓名: 文档中的示例代码如下所示,我使用所需的Facebook id对其进行了修改 /* make the API call */ new Request( session, "/3003345?fields=context", null, HttpMethod.GET, new Request.Callback() { public void onCo

我试图通过使用Facebook社交上下文API从以下文档中获取共同好友数和数据用户id和姓名:

文档中的示例代码如下所示,我使用所需的Facebook id对其进行了修改

/* make the API call */
new Request(
    session,
    "/3003345?fields=context",
    null,
    HttpMethod.GET,
    new Request.Callback() {
        public void onCompleted(Response response) {
            /* handle the result */
        }
    }
).executeAsync();
但是,我的日志显示此错误:

{Response:  responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2500, errorType: OAuthException, errorMessage: Syntax error "Expected end of string instead of "?"." at character 7: context?access_token="accesstoken"}, isFromCache:false}
我用accesstoken替换了访问令牌


有人知道这个问题的解决办法吗?我被困了好几天了。谢谢。

我也有同样的问题,但是在GraphRequest类中,所以我会为它写作

GraphRequest将生成如下URL

  ...facebook.com/3003345?fields=context?access_token=...
而不是

  ...facebook.com/3003345?fields=context&access_token=...
应该如此

解决方案:

  GraphRequest request =  GraphRequest.newGraphPathRequest(session, 3003345,...);

  Bundle parameters = new Bundle();

  parameters.putString("fields", "context");

  request.setParameters(parameters);

  request.executeAsync();