1

我正在使用以下代码来获取我的 facebook 朋友的游戏分数。

    -(void)GetFriendScore
{
    NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                     [NSString stringWithFormat:@"%@", [FBSDKAccessToken currentAccessToken]], @"access_token",
                                     nil];

    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:@"/me/scores"
                                  parameters:params
                                  HTTPMethod:@"GET"];
    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                          id result,
                                          NSError *error) {

    }];
}

并得到以下格式的响应

{
data =     (
            {
            user =             {
                id = XYZ;
                name = "XYZ";
            };
            }
            );

}

但这不是预期的反应。我预期的甲方正在关注

{
data =     (

            {
            application =             {
                category = Games;
                id = XYZ;
                link = "https://www.facebook.com/games/?app_id=XYZ";
                name = "XYZ";
            };
            score = 2907;
            user =             {
                id = XYZ;
                name = "XYZ";
            };
            }
            );

}

谁能帮我得到正确的答复?

4

4 回答 4

0

看起来您正在使用 Graph API v2.4。这样,您必须指定要返回的每个字段。在此处查看我对类似问题的回答:

如果您还想查看朋友的分数,您需要请求/{app_id}/scores?fields=user,application,score而不是我猜/me/scores?fields=user,application,score

或者,

/me?fields=scores{user,application,score},friends{scores{user,application,score}‌​}

应该也可以

于 2015-07-29T09:16:37.400 回答
0

使用以下代码解决。

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                              initWithGraphPath:@"/me/scores?fields=user,application,score"
                              parameters:params
                              HTTPMethod:@"GET"];
于 2015-07-29T10:47:51.950 回答
0

我们如何在android中做同样的事情。我在android中有同样的问题我正在使用以下代码

request = new Request(Session.getActiveSession(), "/ "+"FB_ID"+"/scores?fields=user,application,score", param , HttpMethod.GET);
if(request!=null)
{
    request.setCallback(new Request.Callback()
    {
        public void onCompleted(Response response)
        {
                    if(response!=null)
                    {
                        GraphObject graphObject = response.getGraphObject();
                        if(graphObject==null)
                        {
                            //getting graphObject NULL
                        }

                    }
        }
    }
}

如何解决这个问题

于 2015-07-30T12:03:30.043 回答
0
param.putString("fields", "user,application,score");
request = new Request(Session.getActiveSession(), "/me/scores", param , HttpMethod.GET);
if(request!=null)
{
    request.setCallback(new Request.Callback()
    {
        public void onCompleted(Response response)
        {
                    if(response!=null)
                    {
                        GraphObject graphObject = response.getGraphObject();
                        if(graphObject==null)
                        {
                            //Enjoy
                        }

                    }
        }
    }
}
于 2015-07-30T13:09:30.763 回答