[英]Creating an Facebook Graph API Achievement for a game with iOS SDK
我目前正在开发一款没有画布版本的游戏。 它可以在iOS和Android平台上玩。我需要使用游戏成就对象。 我遵循了Facebook Graph API来创建Achievement 。 我无法理解元标记<meta property="og:url" content="Put your own URL to the object here" />.
我实际上所做的是,启动了自己的服务器并创建了一个.html文件,其内容如“ 标记部分”中所示。 我用http://192.168.2.6:8888/facebooktest/achivement.html
替换了Put your own URL to the object here
。 我使用的代码
- (IBAction)updateAchivement:(id)sender {
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"****888****3612", @"fb:app_id",
@"game.achievement", @"og:type",
@"http://192.168.2.6:8888/facebooktest/achivement.html", @"og:url",
@"Sample Game Achievement", @"og:title",
@"https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png", @"og:image",
@"1000", @"game:points",
nil
];
/* make the API call */
[FBRequestConnection startWithGraphPath:@"/me/objects/" //game.achievement
parameters:params
HTTPMethod:@"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
if (error) {
NSLog(@"%@",error);
}
else
NSLog(@"Result = %@",result);
}];
}
这是我收到的日志
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x8d21ef0 {com.facebook.sdk:HTTPStatusCode=400, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) The parameter object is required";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x8e2ebd0, state: FBSessionStateOpenTokenExtended, loginHandler: 0x8e31d40, appID: 605088866273612, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x8e33240>, expirationDate: 2014-09-22 13:31:23 +0000, refreshDate: 2014-07-25 11:24:16 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(
installed,
"public_profile",
email,
"publish_actions",
"user_friends"
)>}`
我无法弄清楚出了什么问题。 请帮忙...
您应该更正此行:
[FBRequestConnection startWithGraphPath:@"/me/objects/"
至
[FBRequestConnection startWithGraphPath:@"/me/objects/app_namespace:Object_name"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.