【发布时间】:2016-05-20 19:02:39
【问题描述】:
我正在尝试在 facebook 上分享一个图形对象,但我在添加图像时遇到了一些问题。
这是我当前的代码:
// Construct an FBSDKSharePhoto
UIImage* psImg = [UIImage imageNamed:@"fb_share_logo"];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = psImg;
photo.userGenerated = NO;
NSDictionary *properties = @{@"og:type": @"my_obj",
@"og:title": @"Title",
@"og:description": @"Description",
@"og:web": @"http://www.mywebssite.com"
// @"og:image": @[photo]
};
//create GraphObject from properties
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
//create action
FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"my_action" object:object key:@"my_key"];
//create content
FBSDKShareOpenGraphContent *content = [FBSDKShareOpenGraphContent new];
//set content action
content.action = action;
content.previewPropertyName = @"my_prop_type";
FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
shareDialog.fromViewController = self;
shareDialog.shareContent = content;
if (![shareDialog canShow]) {
// update the app UI accordingly
NSLog(@"is showing");
}
NSError *error;
if (![shareDialog validateWithError:&error]) {
// check the error for explanation of invalid content
NSLog(@"error");
}
if([shareDialog canShow]){
[shareDialog show];
}
【问题讨论】:
标签: ios objective-c facebook facebook-graph-api share