我想用sdk把图片和视频分享到面子书墙上。
我使用下面的代码来分享图片
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = [UIImage imageNamed:@"Classic-Guitar.jpg"];
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[照片];
FBSDKShareDialog *shareCodeDialog;
shareCodeDialog = [FBSDKShareDialog new];
[shareCodeDialog setDelegate:self];
[shareCodeDialog setShareContent:content];
[shareCodeDialog setFromViewController:self];
[shareCodeDialog show];
使用此代码我可以在墙上张贴图片,但在发送视频时我使用以下代码
NSURL *videoURL = [[NSURL URLWithString:@"https://www.youtube.com/watch?v=rSAiSTkVMfs"] absoluteURL];
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = videoURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;
FBSDKShareDialog *shareCodeDialog;
shareCodeDialog = [FBSDKShareDialog new];
[shareCodeDialog setDelegate:self];
[shareCodeDialog setShareContent:content];
[shareCodeDialog setFromViewController:self];
[shareCodeDialog show];
但它没有被发布并在代表说中给出了错误 Error Domain=com.facebook.sdk.share Code=2 “操作无法完成。(com.facebook.sdk.share 错误 2。)” UserInfo=0x16d95990 {com.facebook.sdk:FBSDKErrorArgumentValueKey= https://www.youtube.com/watch?v=rSAiSTkVMfs , com.facebook.sdk:FBSDKErrorArgumentNameKey=videoURL, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=videoURL 的无效值:https://www.youtube.com/watch?v=rSAiSTkVMfs
最佳答案
videoURL
属性必须是 Assets URL(从 UIImagePickerController 获取的 URL),而不是本地文件 URL/Web URL(请参阅 https://developers.facebook.com/docs/sharing/ios#videos)
如果您想共享 YouTube 视频(或网站上提供的任何视频),请使用 FBSDKShareLinkContent
(请参阅 https://developers.facebook.com/docs/sharing/ios#links)
关于ios - Facebook 上的视频分享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33122932/