繁体   English   中英

在iOS应用中使用Facebook sdk4.0在Facebook上共享视频

[英]Sharing Video on facebook using facebook sdk4.0 from ios app

在我的iOS移动应用中,我需要在Facebook帐户上共享/上传视频(从照片库或使用相机捕获)。 我正在使用iOS 8.0和FacebookSDK 4.0。 我尝试了很多代码,但是其中任何一个都不起作用。 我已成功完成以下步骤。 1)以“ publish_action”权限登录到Facebook 2)用户在FBSDKAccessToken确实具有有效的访问令牌
如官方FB文件中所述,我已经这样做了

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSURL * selectedVideoUrl = [info objectForKey:UIImagePickerControllerMediaURL];
[self dismissViewControllerAnimated:picker completion:nil];

FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = selectedVideoUrl;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video; 
//here now i have tried both the techniques mentioned below  
}

现在我已经尝试使用FBSDKShareDialog发布此内容,但是它不起作用并引发错误,我也尝试使用FBSDKShareAPI这样

FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.delegate=self;
dialog.fromViewController = self;
dialog.shareContent=content;
[dialog show];

像这样

FBSDKShareAPI *shareRequest= [FBSDKShareAPI shareWithContent:content delegate:self];
if ([shareRequest canShare]) {
    BOOL isSuccess=[shareRequest share];
    if (isSuccess) {
        NSLog(@"shared");
    }
}

我如何使此上传正常工作?

使用UIImagePickerControllerReferenceURL获取资源库URL,而不是UIImagePickerControllerMediaURL

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM