ios - 从 iOS 将视频上传到 facebook - 无法向用户请求登录权限,错误代码 6
<p><p>我正在使用 iOS 6 中的社交框架将 facebook 视频上传集成到我的应用程序中。但是,当我运行该程序时没有任何反应,而是收到以下错误:</p>
<blockquote>
<p>The operation couldn’t be completed. (com.apple.accounts error 6.)</p>
<p>"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}"</p>
</blockquote>
<p>下面是我的代码,前半部分是我从 <a href="http://www.techotopia.com/index.php/IPhone_iOS_6_Facebook_and_Twitter_Integration_using_SLRequest" rel="noreferrer noopener nofollow">tutorial</a> 实现的. <code>granted</code> 设置为 <code>false</code>,导致第一个错误。</p>
<pre><code>- (void)uploadToFb {
ACAccountStore *accountStore = [ init];
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{
ACFacebookAppIdKey: @"2************",
ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],
ACFacebookAudienceKey: ACFacebookAudienceFriends
};
[accountStore requestAccessToAccountsWithType:facebookAccountType
options:options completion:^(BOOL granted, NSError *e) {
if (granted)
{
NSArray *accounts = ;
facebookAccount = ;
}
else
{
NSLog(@"Error %@", e.localizedDescription); }
}
}];
NSURL *videourl = ;
NSString *filePath = ;
NSURL *pathURL = outputURL;
NSData *videoData = ;
NSDictionary *params = @{
@"title": @"Face Puppets Video",
@"description": @"A funny video I made with the #FacePuppets iOS app."
};
SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:videourl
parameters:params];
[uploadRequest addMultipartData:videoData
withName:@"source"
type:@"video/quicktime"
filename:];
uploadRequest.account = facebookAccount;
[uploadRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *responseString = [ initWithData:responseData encoding:NSUTF8StringEncoding];
if(error){
NSLog(@"Error %@", error.localizedDescription);
}else
NSLog(@"%@", responseString);
}];
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>嗨,这是一个非常好的分享示例<a href="https://github.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/wiki/How-To-for-iOS" rel="noreferrer noopener nofollow">iOS (Wiki) (Sample Project for iOS, ~3 MB)</a>使用它,您可以将视频分享到 <strong>Facebook、YouTube、Flicker、Vimeo</strong> 查看上面的链接并测试此示例。</p>
<p>你需要在<code>ESSViewController.m</code>类中设置你的<code>AppId</code> 在这个方法中:</p>
<pre><code>- (IBAction)facebook:(id)sender
{
self.fb = [[ initWithDelegate:self
appID:@"youAppID"
appSecret:@"secret"] autorelease];
NSURL *url = [ URLForResource:@"IMG_1203" withExtension:@"MOV"];
;
}
</code></pre>
<p>这可能是 Facebook 的旧版本,但用于获取有关如何处理来自 ourApp 的共享视频的想法。</p></p>
<p style="font-size: 20px;">关于ios - 从 iOS 将视频上传到 facebook - 无法向用户请求登录权限,错误代码 6,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18653228/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18653228/
</a>
</p>
页:
[1]