[英]iOS Facebook share
After getting grantedPermissions "publish_actions", now I want to users want user to send a message and a image(local generated) to their Facebook timelines without leave current view. 在获得GrantPermissions“ publish_actions”权限之后,现在我希望用户希望用户在不离开当前视图的情况下向其Facebook时间线发送消息和图像(本地生成)。
I have tried FBSDKShareAPI interface, but this is not the effect I want. 我已经尝试过FBSDKShareAPI接口,但这不是我想要的效果。 I hope to implement one status with one message and one image.
我希望以一种消息和一张图像实现一种状态。 How can I do?
我能怎么做?
FBSDKSharePhoto* photo = [[FBSDKSharePhoto alloc]init];
photo.image = self.shareImage;
photo.userGenerated = YES;
FBSDKSharePhotoContent * content = [[FBSDKSharePhotoContent alloc]init];
content.photos = @[photo];
if ([[FBSDKAccessToken currentAccessToken].permissions containsObject:@"publish_actions"]) {
FBSDKShareAPI * shareApi = [[FBSDKShareAPI alloc]init];
shareApi.message = self.tf.text;
[shareApi createOpenGraphObject:object];
[FBSDKShareAPI shareWithContent:content delegate:self];
[shareApi share];
}
You are sharing the same content twice which is probably why you aren't able to get one status message with one image (and instead getting two): 您要共享两次相同的内容,这可能是为什么您无法通过一张图像获得一个状态消息(而是获得两个)的原因:
[FBSDKShareAPI shareWithContent:content delegate:self];
[shareApi share];
And you probably don't need to create an open graph object for the same. 而且您可能不需要为此创建一个开放图对象。 Try this:
尝试这个:
NSURL *imageURL = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/en/d/d3/Nasa_mer_marvin.jpg"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; // taking image from Wikipedia for example purposes
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image; // photo.image = self.shareImage;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
if ([[FBSDKAccessToken currentAccessToken].permissions containsObject:@"publish_actions"]) {
FBSDKShareAPI * shareApi = [[FBSDKShareAPI alloc]init];
shareApi.message = @"Lorem Ipsum Dolor Sit Amet"; // shareApi.message = self.tf.text;
shareApi.shareContent = content;
[shareApi share];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.