facebook分享成就问题

时间:2015-05-09 03:47:37

标签: ios objective-c facebook-graph-api

我正在尝试使用以下代码添加分享游戏成就。但是,我在发布时遇到错误:error_reason未完成的操作(“FBAPIErrorDomain错误100”)error_description @“发布期间发生错误”。 有人有主意吗?

// Create share photo by path
NSString* picPath = [NSString stringWithUTF8String:path];
UIImage *img = [UIImage imageWithContentsOfFile: picPath];

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = img;
photo.userGenerated = YES;

// Create Object
NSDictionary *properties = @{
                             @"og:type": @"game.achievement",
                             @"og:title": @"Game Achievement Title",
                             @"og:description": @"Game Achievement Desc",
                             @"og:url": @"http://www.baidu.com",
                             @"og:image": @[photo]
                            };
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

// Create Action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"games.achieves";
//[action setString:@"testtest" forKey:@"achievement"];
[action setObject:object forKey:@"game.achievement"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"game.achievement";

// show share dialog
FBSDKShareDialog *_shareDialog = [[FBSDKShareDialog alloc] init];
_shareDialog.delegate = s_shareDelegate;
_shareDialog.shouldFailOnDataError = YES;
_shareDialog.shareContent = content;
_shareDialog.fromViewController = (UIViewController *)[AppController getRootViewController];
[_shareDialog show];

2 个答案:

答案 0 :(得分:0)

游戏:game.achievement对象需要点属性。将其添加到您的属性对象:

 @"game:points": @"1",

供参考,请参阅https://developers.facebook.com/docs/reference/opengraph/object-type/game.achievement/

答案 1 :(得分:0)

如果已经为用户提供了成就,则他无法再次实现,在使用FBSDKShareDialog时会导致didFailWitgError。 希望它会有所帮助