我已经关注了带有消息的视频帖子的Facebook文档。
示例代码如下:
NSURL *urlString = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"]];
NSData *videodata=[NSData dataWithContentsOfURL:urlString];
NSURL *imgUrl=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"images" ofType:@"jpg"]];
NSData *imagedata=[NSData dataWithContentsOfURL:imgUrl];
NSDictionary *params = @{
@"source": videodata,
@"thumb": imagedata,
@"description":@"#BHARAT",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"videos"
parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
NSLog(@" Result-%@",result);
NSLog(@"Error=%@",error);
}];
但它给我的错误如下
错误=错误域= com.facebook.sdk.core代码= 8"操作无法完成。 (com.facebook.sdk.core错误8。)"的UserInfo = 0x16547ac0 {com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey = 500,com.facebook.sdk:FBSDKErrorDeveloperMessageKey =发生未知的错误,NSRecoveryAttempter = LT; _FBSDKTemporaryErrorRecoveryAttempter:0x16555040>中com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode = 1,玉米。 facebook.sdk:FBSDKGraphRequestErrorCategoryKey = 1,com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey = { body = { error = { code = 1; message ="发生了未知错误。&#34 ;; type = OAuthException; }; }; 代码= 500; },NSLocalizedRecoveryOptions =( 好 ),NSLocalizedRecoverySuggestion =服务器暂时忙,请再试一次。}
请提供示例代码。
答案 0 :(得分:1)
尝试使用下面的代码
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *urlString = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"]];
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = videoURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;
...
// Assuming self implements <FBSDKSharingDelegate>
[FBSDKShareAPI shareWithContent:content delegate:self];
}
注意:视频应该小于12 MB