如何在Graph API 2.9 for iOS中的FBSDKShareDialog中共享网站

时间:2017-07-06 21:43:44

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

您好我一直在尝试使用FBSDKShareDialog for iOS(FB SDK)实现类似的共享网站的解决方案。从2017年7月起,我的当前实施已被弃用:

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = @"http://www.ironmaiden.com";
content.contentTitle = @"This is the best band ever"; 
content.imageURL = @"http://ironmaiden.com/media/images/book-of-souls-bg.png";     
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];

最接近的解决方案是使用FBSDKShareOpenGraphObject并设置元标记:

 NSDictionary *properties = @{
                             @"og:type": @"website",
                             @"og:title": @"Up the Irons",
                             @"og:description": @"This is the best band ever",
                             @"og:image": @"http://ironmaiden.com/media/images/book-of-souls-bg.png",
                             @"og:url": @"http://www.ironmaiden.com"
                             };
 FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

 FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
 action.actionType = @"og.likes";
 [action setObject:object forKey:@"og:object"];

 FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
 content.action = action;
 content.previewPropertyName = @"og:object";

 FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];

这很好用,除非我分享它时动作显示为: See example image here

Username likes an object on Iron Maiden Fan.:如何将object重命名为website之类的其他内容?

我在文档中找到了:

This action and associated object types are automatically added to the App Dashboard when you use the action for the first time.

但这不是很有帮助,显然我在FB Dashboard或FBSDKShareOpenGraphObject声明中缺少一些设置,我感谢任何帮助

0 个答案:

没有答案