在我的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");
}
}
如何让这个上传工作?
答案 0 :(得分:2)
使用UIImagePickerControllerReferenceURL
获取资产库网址而不是UIImagePickerControllerMediaURL
。