通过shareDialog或feedDialog分享OpenGraph故事

时间:2016-06-21 16:29:07

标签: ios facebook-graph-api

我正在使用Facebook SDK 4.13 for iOS。

我通过[FBSDKShareAPI share]成功分享了自定义OpenGraph故事。问题是 - 没有对话。

当我尝试通过FBSDKShareDialog分享相同的上下文时 - 对话框显示为空并且不共享帖子。

是否有可能通过对话分享OpenGraph故事?

1 个答案:

答案 0 :(得分:0)

我为我的OGOStory( OpenGraphObjectStory )管理了“调整”设置,因此它会在精细对话框中正确显示。 有点令人困惑的是,在我的应用程序中,我有名为 story 和OGOS的模型,但我希望你能理解。

- (void)performShareFacebookWithStory:(STLStory *)story andText:(NSString *)text
{
    NSURL *imageURL = [NSURL URLWithString:[story largeImageURL]];
    FBSDKSharePhoto *photo = [FBSDKSharePhoto photoWithImageURL:imageURL userGenerated:NO];
    NSDictionary *properties = @{
                                 @"og:type": @"stories_california:story", //OpenGraphObjectStory,
                                 @"og:title": [story title],
                                 @"og:description": [story aboutText],
                                 @"og:url": [self storyUrlForStory:story], // it's NSString
                                 @"og:image": @[photo],
                                 };
    FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

    FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
    action.actionType = @"stories_california:story_listen";
    [action setObject:object forKey:@"story"];

    FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
    content.action = action;
    content.previewPropertyName = @"story"; //OpenGraphPreviewPropertyName

    [FBSDKShareDialog showFromViewController:_parentVC
                                 withContent:content
                                    delegate:self];
}