上传视频到Facebook错误5 [英] uploading video to Facebook error 5

查看:212
本文介绍了上传视频到Facebook错误5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从我的iPhone上传视频到Facebook。我已经使用FBLoginView登录并创建了一个FBSession。

   - (void)buttonRequestClickHandler:(id)sender { 

if(FBSession.activeSession.isOpen){

[FBSession.activeSession requestNewPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceOnlyMe
completionHandler:nil];

NSString * audioName = [pictureDictionary4 objectForKey:@photoVideokey];
NSArray * pathsa = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString * documentsDirectorya = [pathsa objectAtIndex:0];
NSString * moviePath = [documentsDirectorya stringByAppendingPathComponent:@/ Movie];
NSString * fullPatha = [moviePath stringByAppendingPathComponent:audioName];方信息亦读地信范读亦读读中的信息中读亦或信息
NSData * videoData = [NSData dataWithContentsOfFile:fullPatha];

NSString * titleString = self.videotitle.text;
NSString * descripString = self.descrp.text;

NSDictionary * videoObject = @ {
@title:titleString,
description:descripString,
[pathURL absoluteString]:videoData
};
FBRequest * uploadRequest = [FBRequest requestWithGraphPath:@me / videos
parameters:videoObject
HTTPMethod:@POST];
$ b $ [uploadRequest startWithCompletionHandler:^(FBRequestConnection * connection,id result,NSError * error){
if(!error)
NSLog(@Done:%@,result );
else
NSLog(@Error:%@,error.localizedDescription);
}];

$ / code> $ / pre>

我得到一个错误
错误:操作不能完成。 (com.facebook.sdk error 5。)



我不确定这个错误是怎么回事:

我知道我登录了



我不知道我是否正在连接,但是我正在使用iPhone上网



我的参数不正确吗?
我一直在搞这个小时,没有结果
任何人/每个人的任何帮助将不胜感激。



最后得到这个工作进入我的iPhone设置-Facebook并删除我的帐户。然后当我点击上传在我的应用程序中的视频,它加载了一个视图,询问Facebook是否可以使用我的应用程序,我说是,然后BAM它上传。也必须将我的权限更改为publish_actions并摆脱publish_streams,因为这是一个读取权限。无论如何,它现在正在工作。接下来获得defaultAudience从用户选择的字符串加载,而不是硬编码。另外一个帖子。 FaceBook SDK 3.14.1
$ b

建议:在.plist文件中有3个属性

设置FacebookAppID,FacebookDisplayName,

URL类型 - >项目0-> URL Schemes设置为facebookappId前缀 fb 请参阅

   - (void)shareOnFaceBook 
{
//sample_video.mov是文件名
NSString * filePathOfVideo = [[NSBundle mainBundle] pathForResource:@sample_videoofType:@mov];

NSLog(@Path Of Video is%@,filePathOfVideo);
NSData * videoData = [NSData dataWithContentsOfFile:filePathOfVideo];
//你可以使用dataWithContentsOfURL如果你有一个Url的视频文件
// NSData * videoData = [NSData dataWithContentsOfURL:shareURL];
// NSLog(@data is:%@,videoData);
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData,@video.mov,
@video / quicktime,@contentType,
@Video name ,@name,
@Video of Video的描述,@description,
nil];

if(FBSession.activeSession.isOpen)
{
[FBRequestConnection startWithGraphPath:@me / videos
parameters:params
HTTPMethod:@ POST
completionHandler:^(FBRequestConnection * connection,id result,NSError * error){
if(!error)
{
NSLog(@RESULT:%@,结果);
[self throwAlertWithTitle:@成功消息:@Video uploaded];

else
{
NSLog(@ERROR:%@,error.localizedDescription);
[self throwAlertWithTitle:@Deniedmessage:@Try Again];
}
}];



NSArray * permissions = [[NSArray alloc] initWithObjects:
@publish_actions,
nil];
//打开会话!
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES
completionHandler:^(FBSession * session,
FBSessionState status,
NSError * error){
if(error )
{
NSLog(@Login fail:%@,error); (FB_ISSESSIONOPENWITHSTATE(status))
{
[FBRequestConnection startWithGraphPath:@me / videos
parameters:params
HTTPMethod:@

else if POST
completionHandler:^(FBRequestConnection * connection,id result,NSError * error){
if(!error)
{
[self throwAlertWithTitle:@Successmessage :@上传的视频];

NSLog(@RESULT:%@,result);
}
else
{
[self throwAlertWithTitle:@Deniedmessage:@Try Again];

NSLog(@ERROR:%@,error.localizedDescription);
}

}];
}
}];


$ / code $ / pre
$ b $我和GOT错误:

 操作无法完成。 (com.facebook.sdk错误5.)

当facebook被inited时发生。下一次我打开我的应用程序,它工作正常,它总是第一次。尝试了一切应用程序,但似乎是在Facebook SDK方面。



几个原因看到 com.facebook.sdk错误5




  • 会话未打开。验证。

  • Facebook检测到您在发送垃圾邮件。更改视频名称。

  • Facebook使用SDK有一个定义的限制。尝试使用其他应用程序。 错误的发布权限。给 publish_actions 自旋。


I am trying to upload a video from my iPhone to Facebook. I have logged in using FBLoginView and created a FBSession. I have used the following code to initiate a FBRequest of upload the video.

- (void)buttonRequestClickHandler:(id)sender {

if (FBSession.activeSession.isOpen) {

    [FBSession.activeSession requestNewPublishPermissions:permissions
                                    defaultAudience:FBSessionDefaultAudienceOnlyMe
                                        completionHandler:nil];        

    NSString *audioName = [pictureDictionary4 objectForKey:@"photoVideokey"];
    NSArray *pathsa = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectorya = [pathsa objectAtIndex:0];
    NSString *moviePath = [documentsDirectorya stringByAppendingPathComponent:@"/Movie"];
    NSString *fullPatha = [moviePath stringByAppendingPathComponent:audioName];
    NSURL *pathURL = [[NSURL alloc]initFileURLWithPath:fullPatha isDirectory:NO];
    NSData *videoData = [NSData dataWithContentsOfFile:fullPatha];

    NSString *titleString = self.videotitle.text;
    NSString *descripString = self.descrp.text;

    NSDictionary *videoObject = @{
                                  @"title":titleString,
                                  @"description": descripString,
                                  [pathURL absoluteString]: videoData
                                  };
    FBRequest *uploadRequest = [FBRequest requestWithGraphPath:@"me/videos"
                                                    parameters:videoObject
                                                    HTTPMethod:@"POST"];

   [uploadRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (!error)
            NSLog(@"Done: %@", result);
        else
            NSLog(@"Error: %@", error.localizedDescription);
    }];
}

I get an error Error: The operation couldn’t be completed. (com.facebook.sdk error 5.)

I'm not sure what the error pertains to:

I know I'm logged in

I don't know if I am getting connected but I am on internet with iPhone

Are my parameters incorrect? I have been messing with this for HOURS with no results Any help from anyone/everyone would be greatly appreciated.

Finally got this working by going into my iPhone settings-facebook and deleting my account. Then when I tapped to upload the video in my app it loaded a view that asked if Facebook could use my app and I said yes then bam it uploaded. Also had to change my permissions to just publish_actions and get rid of publish_streams since that is a read permission. Anyway it is working now. Next to get defaultAudience to load from a string picked by user and not hard coded. Another post.

解决方案

This Code is Tested successfully On FaceBook SDK 3.14.1

Recommendation: 3 properties in .plist file

set FacebookAppID,FacebookDisplayName,
URL types->Item 0->URL Schemes set to facebookappId prefix with fb See

-(void)shareOnFaceBook
{
    //sample_video.mov is the name of file
    NSString *filePathOfVideo = [[NSBundle mainBundle] pathForResource:@"sample_video" ofType:@"mov"];

    NSLog(@"Path  Of Video is %@", filePathOfVideo);
    NSData *videoData = [NSData dataWithContentsOfFile:filePathOfVideo];
    //you can use dataWithContentsOfURL if you have a Url of video file
    //NSData *videoData = [NSData dataWithContentsOfURL:shareURL];
    //NSLog(@"data is :%@",videoData);
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               videoData, @"video.mov",
                               @"video/quicktime", @"contentType",
                               @"Video name ", @"name",
                               @"description of Video", @"description",
                               nil];

   if (FBSession.activeSession.isOpen)
   {
        [FBRequestConnection startWithGraphPath:@"me/videos"
                                 parameters:params
                                 HTTPMethod:@"POST"
                          completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                              if(!error)
                              {
                                  NSLog(@"RESULT: %@", result);
                                  [self throwAlertWithTitle:@"Success" message:@"Video uploaded"];
                              }
                              else
                              {
                                  NSLog(@"ERROR: %@", error.localizedDescription);
                                  [self throwAlertWithTitle:@"Denied" message:@"Try Again"];
                              }
                          }];
    }
    else
    {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"publish_actions",
                            nil];
        // OPEN Session!
        [FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone  allowLoginUI:YES
                                     completionHandler:^(FBSession *session,
                                                         FBSessionState status,
                                                         NSError *error) {
                                         if (error)
                                         {
                                             NSLog(@"Login fail :%@",error);
                                         }
                                         else if (FB_ISSESSIONOPENWITHSTATE(status))
                                         {
                                             [FBRequestConnection startWithGraphPath:@"me/videos"
                                                                          parameters:params
                                                                          HTTPMethod:@"POST"
                                                                   completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                                                       if(!error)
                                                                       {
                                                                           [self throwAlertWithTitle:@"Success" message:@"Video uploaded"];

                                                                           NSLog(@"RESULT: %@", result);
                                                                       }
                                                                       else
                                                                       {
                                                                           [self throwAlertWithTitle:@"Denied" message:@"Try Again"];

                                                                           NSLog(@"ERROR: %@", error.localizedDescription);
                                                                       }

                                                                   }];
                                         }
                                     }];
        }
}

And I GOT Error:

 The operation couldn’t be completed. (com.facebook.sdk error 5.)

It happens when facebook is being inited. Next time i open my app, it works fine, its always the first time. Tried everything in app, but it seems to be on the Facebook SDK side.

Few causes for seeing com.facebook.sdk error 5:

  • Session is is not open. Validate.
  • Facebook has detected that you're spamming the system. Change video name.
  • Facebook has a defined limit using the SDK. Try a different app.
  • Wrong publish permission. Give publish_actions a spin.

这篇关于上传视频到Facebook错误5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆