【发布时间】:2012-08-19 18:09:45
【问题描述】:
我正在尝试将 Twitter 帐户保存到 ACAccountStore。
我正在使用MPOauth 对用户进行身份验证(这非常有效,我可以进行身份验证并发布消息),当我收到访问令牌和访问令牌密码时,我会继续保存帐户。
首先,我将令牌访问拆分为只获取令牌本身,而不是用户 ID。之后这是我的代码
if ([username length] > 0 && [token length] > 0 && [secret length] > 0) {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
ACAccount *account = [[ACAccount alloc] initWithAccountType:accountType];
ACAccountCredential *credentials = [[ACAccountCredential alloc] initWithOAuthToken:token tokenSecret:secret];
[account setCredential:credentials];
[account setUsername:username];
[accountStore saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"the account was saved!");
} else {
NSLog(@"the account was NOT saved");
}
[accountStore release];
[account release];
[credentials release];
}];
}
但从来没有用过,我明白了
Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)"
我读到这会响应针对 Twitter 验证数据的错误,这是由 iOS5 框架在保存帐户之前完成的。
我已经阅读了this reponse 和Twitter 中的帖子。
怎么了?
【问题讨论】:
标签: ios ios5 twitter acaccount