使用iOS6 Social Framework将视频上传到Facebook

使用iOS6 Social Framework将视频上传到Facebook,第1张

概述我想将视频文件发布到Facebook.以前我使用Facebook iOS SDK3.0,它的工作原理.但是,对于iOS6社交框架,存在问题. __block ACAccount * facebookAccount; ACAccountStore* accountStore = [[ACAccountStore alloc] init]; NSDictionary *options 我想将视频文件发布到Facebook.以前我使用Facebook iOS SDK3.0,它的工作原理.但是,对于iOS6社交框架,存在问题.

__block ACAccount * facebookAccount;    ACAccountStore* accountStore = [[ACAccountStore alloc] init];    NSDictionary *options = @{    ACFacebookAppIDKey: @"MY APP ID",ACFacebookPermissionsKey: @[@"publish_actions",],@"ACFacebookAudIEnceKey": ACFacebookAudIEnceFrIEnds    };    ACAccountType *facebookAccountType = [accountStore                                          accountTypeWithAccountTypeIDentifIEr:ACAccountTypeIDentifIErFacebook];    [accountStore requestAccesstoAccountsWithType:facebookAccountType options:options completion:^(BOol granted,NSError *error) {        if (granted) {            NSArray *accounts = [accountStore                                 accountsWithAccountType:facebookAccountType];            facebookAccount = [accounts lastObject];            NSLog(@"access to facebook account ok %@",facebookAccount.username);            NSData *vIDeoData = [NSData dataWithContentsOffile:[self vIDeofileFullPath]];            NSLog(@"vIDeo size = %d",[vIDeoData length]);            NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:                                     vIDeoData,@"vIDeo.mov",@"vIDeo/quicktime",@"ContentType",@"VIDeo Title",@"Title",@"VIDeo description",@"description",nil];            NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me/vIDeos"];            SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook                                                                         requestMethod:SLRequestMethodPOST                                                                                   URL:requestURL                                                                            parameters:params];            request.account = facebookAccount;            [request performRequestWithHandler:^(NSData *data,NShttpURLResponse *response,NSError * error){                NSLog(@"response = %@",response);                NSLog(@"error = %@",[error localizedDescription]);            }];        } else {            NSLog(@"access to facebook is not granted");            // extra handling here if necesary        }    }];

Terminating app due to uncaught exception
‘NSinvalidargumentexception’,reason: ‘-[NSConcreteData
_fastCharacterContents]: unrecognized selector sent to instance 0x2097ead0’

解决方法 这是我的研究:
首先,视频数据不能成为参数列表的一部分,因为它会使SLRequest无效,这就是您遇到的崩溃.

视频数据必须包含在请求的多部分部分中.

现在,需要将参数与多部分数据相关联,这是棘手的部分.因此有必要使用source属性来建立该链接.

Source需要一个字符串格式的URL,在参数中设置它,并在multipart请求的filename字段中设置相同的值.

应该这样做.

NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/vIDeos"];NSURL *vIDeoPathURL = [[NSURL alloc]initfileURLWithPath:vIDeoPath isDirectory:NO];NSData *vIDeoData = [NSData dataWithContentsOffile:vIDeoPath];Nsstring *status = @"One step closer.";NSDictionary *params = @{@"Title":status,@"description":status};SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook                                        requestMethod:SLRequestMethodPOST                                                   URL:url                                            parameters:params];[request addMultipartData:vIDeoData                 withname:@"source"                     type:@"vIDeo/quicktime"                  filename:[vIDeoPathURL absoluteString]];
总结

以上是内存溢出为你收集整理的使用iOS6 Social Framework将视频上传到Facebook全部内容,希望文章能够帮你解决使用iOS6 Social Framework将视频上传到Facebook所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1053406.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存