Iphone 在iOS5上创建twitter帐户时出错:nsurErrorDomain错误-1012
我在iOS5上创建并保存新twitter帐户到Iphone 在iOS5上创建twitter帐户时出错:nsurErrorDomain错误-1012,iphone,twitter,ios5,accounts,Iphone,Twitter,Ios5,Accounts,我在iOS5上创建并保存新twitter帐户到ACAccountStore时遇到问题 执行初始化帐户的所有步骤后,ACAccountStore的saveAccount:withCompletionHandler:返回nsurErrorDomainError-1012 有人有类似的问题吗 下面的代码示例使用requestToken初始化acAccountCredential。此对象是一个OAToken(ShareKit对象),在完成OAuth后,使用从twitter收到的令牌和机密进行初始化
ACAccountStore
时遇到问题
执行初始化帐户的所有步骤后,ACAccountStore的
saveAccount:withCompletionHandler:
返回nsurErrorDomainError-1012
有人有类似的问题吗
下面的代码示例使用requestToken初始化acAccountCredential
。此对象是一个OAToken
(ShareKit对象),在完成OAuth
后,使用从twitter收到的令牌和机密进行初始化
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]);
}
}];
}
}];
奇怪的是,苹果公司建议saveAccount:withCompletionHandler:
尝试执行OAuth
本身:
如果帐户类型支持身份验证,但该帐户未经身份验证,则该帐户已通过身份验证
使用其凭据。如果认证成功,则保存账户;否则,将不保存它
我发现这很奇怪,因为用户无法通过输入用户名/密码直接向服务器进行身份验证
我还尝试使用我的应用程序的使用者密钥和使用者密钥初始化ACAccountCredential
,结果相同(由于nsurErrorDomain错误-1012而失败。
)
我们将非常感谢您对本主题的任何指导
谢谢。我在添加带有帐户的Twitter帐户时遇到同样的问题。但是,我能够使用授权的OAuth访问令牌和访问令牌密钥(而不是消费者密钥和消费者密钥)成功地创建一个带有account的Twitter帐户。(dev.twitter.com/apps->twitter->OAuth->OAuth设置-->访问令牌和访问令牌机密)这意味着当用户添加twitter帐户时,您仍然必须使用OAuth库来获取授权访问令牌和访问令牌机密 更新:您可以看到Twitter如何建议您将现有帐户迁移到iOS5系统帐户。该链接为我提供了如何添加ACAccount的最佳示例