我正试图在iOS上向Facebook发布OpenGraph故事。我一直在关注这个教程。
https://developers.facebook.com/docs/ios/open-graph/
我也一直在推荐
我可以将帖子上传到FB,但图片丢失了。我尝试了几种变体,但发现文档很稀疏。任何见解将不胜感激:
UIImage *loadedImage = [UIImage imageWithContentsOfFile:file];
NSArray* image = @[@{@"url":loadedImage, @"user_generated": @"true"}];
id<FBGraphObject> objectname =
[FBGraphObject openGraphObjectForPostWithType:@"namespacename:objectname"
title:@"objectname"
image:nil
url:nil
description:@"description"];
id<FBOpenGraphAction> actionname = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[actionname setObject:image forKey:@"image"];
[actionname setObject:objectname forKey:@"objectname"];
// Check if the Facebook app is installed and we can present the share dialog
FBOpenGraphActionParams *params = [[FBOpenGraphActionParams alloc] init];
params.action = actionname;
params.actionType = @"namespacename:objectname";
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params]) {
[FBDialogs presentShareDialogWithOpenGraphAction:actionname
actionType:@"namespacename:actionname"
previewPropertyName:@"objectname"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// There was an error
NSLog(@"Error publishing story: %@", error.description);
} else {
// Success
NSLog(@"result %@", results);
}
}];
} else {
NSLog(@"cant show the share dialog ");
}
我已经彻底检查了代码,我发现的唯一区别是,我不是从图库中选择图像,而是从文件中加载它。正如我所提到的那样,帖子经过并在Facebook上共享,但图片不会出现在Feed或新闻Feed上的可点击对象中。当共享对话框加载时,我可以看到图像的缩略图,所以我相信它正在加载正常。任何帮助,将不胜感激。提前谢谢。