Facebook上的视频分享

时间:2015-10-14 10:29:24

标签: ios facebook

我想使用sdk在脸书墙上分享图像和视频。

我使用以下代码来分享图片

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = [UIImage imageNamed:@"Classic-Guitar.jpg"];
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];

content.photos = @ [photo];

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 error 2.)”UserInfo = 0x16d95990 {com.facebook.sdk:FBSDKErrorArgumentValueKey = {{3 },com.facebook.sdk:FBSDKErrorArgumentNameKey = videoURL,com.facebook.sdk:FBSDKErrorDeveloperMessageKey = videoURL的值无效:https://www.youtube.com/watch?v=rSAiSTkVMfs}

1 个答案:

答案 0 :(得分:1)

videoURL属性必须是资产URL(来自UIImagePickerController的属性)而不是本地文件URL / Web URL(请参阅https://developers.facebook.com/docs/sharing/ios#videos

如果您想分享YouTube视频(或网站上提供的任何视频),请改用FBSDKShareLinkContent(参见https://developers.facebook.com/docs/sharing/ios#links