我目前正在开发一款没有画布版本的游戏。它可以在iOS和Android平台上播放。我需要使用游戏成就对象。我跟着Facebook Graph API for creating Achievement 。我无法理解元标记<meta property="og:url" content="Put your own URL to the object here" />.
我实际上做的是创建了自己的服务器,并创建了一个带有内容的.html文件,如Mark Up Section所示。我将Put your own URL to the object here
替换为http://192.168.2.6:8888/facebooktest/achivement.html
。我用过的代码
- (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"
)>}`
我无法弄清楚出了什么问题。请帮忙......
答案 0 :(得分:0)
你应该纠正这一行:
[FBRequestConnection startWithGraphPath:@"/me/objects/"
到
[FBRequestConnection startWithGraphPath:@"/me/objects/app_namespace:Object_name"