我在创建和保存iOS5上ACAccountStore
的新Twitter帐户时遇到问题。在iOS5上创建twitter ACAccount时出错:NSURLErrorDomain错误-1012
执行完初始帐户的所有步骤后,ACAccountStore's
saveAccount:withCompletionHandler:
返回NSURLErrorDomain error -1012
。
有没有人有类似的问题?
我的代码示例如下使用requestToken来初始化ACAccountCrendential
。此对象是一个OAToken
(ShareKit对象),使用令牌和秘密在完成OAuth
后收到的密码初始化。
ACAccountStore *store = [[[ACAccountStore alloc] init] autorelease];
ACAccountType *twitterAccountType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
ACAccount *account = [[[ACAccount alloc] initWithAccountType:twitterAccountType] autorelease];
account.username = @"twitterusername";
account.credential = [[[ACAccountCredential alloc] initWithOAuthToken:requestToken.key tokenSecret:requestToken.secret] autorelease];
[store requestAccessToAccountsWithType:twitterAccountType withCompletionHandler:^(BOOL granted, NSError *error) {
if (granted) {
[store saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"TWITTER ACCOUNT CREATED SUCCESSFULLY!");
}
else{
NSLog(@"ERROR creating twitter account: %@", [error description]);
}
}];
}
}];
奇怪的是,苹果的Accounts Framework Reference表明saveAccount:withCompletionHandler:
尝试执行OAuth
本身:使用其凭据
如果帐户类型支持认证和帐户未通过身份验证,该帐户被认证 。如果认证成功,则保存帐户;否则,它不会被保存。
我觉得很奇怪,因为用户无法通过输入用户名/密码直接与服务器进行身份验证。
我也试图与我的应用程序的消费者密钥和消费者秘密进行初始化ACAccountCredential
,具有相同的结果(与NSURLErrorDomain error -1012.
失败)
有关这个主题的任何指导,将不胜感激!
谢谢。