我想通过Open Graph将游戏成就故事分享给facebook以下是创建开放图形对象的代码
NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
object.provisionedForPost = YES;
object[@"title"] = @"Playing";
object[@"type"] = @"game.achievement";
object[@"description"] = @"I just hit 1000 km";
object[@"url"] = @"https://www.facebook.com/";
object[@"image"] = @[@{@"url": [result objectForKey:@"uri"], @"user_generated" : @"false" }];
object[@"game:points"] = @"100";
[FBRequestConnection
startForPostOpenGraphObject:object
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {}];
我收到这个错误信息
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)"
这是应答体
body = {
error = {
code = 100;
message = "(#100) Object Missing a Required Value: Object at URL 'https://www.facebook.com/' of type 'game.achievement' is invalid because a required property 'game:points' of type 'integer' was not provided.";
type = OAuthException;
};
};
code = 400;
我知道这个错误是不言自明的,但我怎么能把一个整数值传递给字典呢。此外,我确实尝试过传递NSNumber值,但没有成功。这是游戏成就对象的文档链接使用开放图对象共享游戏成就
这是对我有用的答案。
只需将其封装在数据值中:
object[@"data"][@"game:points"] = @"100";