我需要发布一个包含用户生成图像的 OpenGraph 故事,而无需请求任何权限。
我遵循了这里发布的官方教程:https://developers.facebook.com/docs/sharing/opengraph/ios
这是我的代码:
NSDictionary *properties = @{@"og:type": @"minidraw-two.illustration",
@"og:title": @"Illustration",
@"og:description": @"iOS Vector illustration app"};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
// Construct an FBSDKSharePhoto
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"minidraw-two.create" object:object key:@"minidraw-two:illustration"];
[action setPhoto:photo forKey:@"image"];
FBSDKShareOpenGraphContent *content = [FBSDKShareOpenGraphContent new];
content.action = action;
content.previewPropertyName = @"minidraw-two:illustration";
[FBSDKShareDialog showFromViewController:viewController
withContent:content
delegate:self];
发布此内容时,我收到以下错误:
我不太确定这个错误是什么意思。我检查了 StackOverflow、Facebook 文档,但一无所获。
请指教。
最佳答案
阅读 this FB bug report 后,我将照片分享出去,没有任何错误。关键是将照片附加到 Open Graph 对象 而不是 Action 。
// Add the photo to the OG object
[object setPhoto:photo forKey:@"og:image"];
照片仍然没有显示全角,但这已被 FB 识别为 v4.0.1 中的有效错误,我会在听到他们的更多消息后立即更新此答案。
更新:根据 FB 的说法,照片不会在 Open Graph 故事上全角显示是设计使然。
关于iOS Facebook 4.0 SDK Share OpenGraph story with UIImage error,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29509824/