在Facebook上设置和检索iOS应用程序的高分

时间:2014-10-22 17:13:28

标签: ios facebook facebook-graph-api

我想在Facebook上发布iOS应用中的高分。我已经阅读了Scores API,但它确实解释了我的理解我的高分(例如int score变量)将如何以编程方式从我的代码链接到Facebook。我也按照以下说明操作:

enter image description here

并且收到以下错误。

enter image description here

我真的很感激一些帮助。感谢。

更新:

我使用以下代码更新Facebook上的分数:

    -(void)postScoreToFacebook:(int)currentScore
{
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                  [NSString stringWithFormat:@"%@", @"4356"], @"score",
                                  nil];
    NSLog(@"Fetching current score");
    // Get the score, and only send the updated score if it's highter
    [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/scores",  @"XXXXX"] parameters:params HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (result && !error) {
            int nCurrentScore = [[[[result objectForKey:@"data"] objectAtIndex:0]  objectForKey:@"score"] intValue];
            NSLog(@"Current score is %d", nCurrentScore);
            if (currentScore > nCurrentScore) {
                NSLog(@"Posting new score of %d", currentScore);
                [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/scores", @"XXXXX"] parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                    NSLog(@"Score posted");
                }];
            }
            else {
                NSLog(@"Existing score is higher - not posting new score");
            }
        }
    }];
}

使用图谱API /USER_ID/scores

检查分数时,我一直收到以下错误
{
  "error": {
    "message": "Unsupported post request. Please read the Graph API documentation at  https://developers.facebook.com/docs/graph-api",
    "type": "GraphMethodException",
    "code": 100
  }
}

1 个答案:

答案 0 :(得分:0)

您应该使用要更新其分数的用户的用户ID,而不是字符串USER_ID