ios - 我想使用我的 iOS 应用程序在 Facebook 墙上发布带有自定义文本的视频

标签 ios facebook-graph-api video

我已关注 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);
}];

但它给我的错误如下

Error=Error Domain=com.facebook.sdk.core Code=8 "The operation couldn’t be completed. (com.facebook.sdk.core error 8.)" UserInfo=0x16547ac0 {com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=500, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An unknown error has occurred., NSRecoveryAttempter=<_FBSDKTemporaryErrorRecoveryAttempter: 0x16555040>, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=1, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=1, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={ body = { error = { code = 1; message = "An unknown error has occurred."; type = OAuthException; }; }; code = 500; }, NSLocalizedRecoveryOptions=( OK ), NSLocalizedRecoverySuggestion=The server is temporarily busy, please try again.}

请提供示例代码。

最佳答案

尝试使用下面的代码

 - (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

关于ios - 我想使用我的 iOS 应用程序在 Facebook 墙上发布带有自定义文本的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31694303/

相关文章:

facebook - 如何使用 Facebook Graph API 获取用户位置

permissions - Facebook Graph API,扩展权限的最终列表

android - 使用 native 视频播放器在 Android 上全屏播放视频

ios - 如何从照片库等设备库中挑选/浏览音频文件?

ios - registerDefaults 未反射(reflect)在设置应用程序中

plist 中 UICollectionView 中的 iOS 部分 - 从 UILabel 分配给 NSString 的不兼容指针类型

video - 通过降低质量来提高 ffmpeg CPU 使用率

类型为 () -> () 的 iOS Swift 函数

Facebook 图形 API : (#100) The After Cursor specified exeeds the max limit supported by this endpoint

video - 使用 ffmpeg 为 Media Source Extensions API 准备 mp4 视频