gpt4 book ai didi

ios - 为什么保存Twitter ACAccount时出现此错误?

转载 作者:行者123 更新时间:2023-12-01 16:55:36 25 4
gpt4 key购买 nike

我正在尝试将Twitter帐户保存到ACAccountStore中。

我正在使用MPOauth对用户进行身份验证(这非常有效,我可以进行身份​​验证并发布消息),并且当我收到访问 token 和访问 token 密码时,我将继续保存该帐户。

首先,我将 token 访问拆分为仅获取 token 本身,而不获取用户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 reponseTwitter中的文章。

怎么了?

最佳答案

如果 token 是OAToken,则应替换为

ACAccountCredential *credentials = [[ACAccountCredential alloc] initWithOAuthToken:token tokenSecret:token];

有了这个
ACAccountCredential *outhCredential = [[ACAccountCredential alloc] initWithOAuthToken:token.key tokenSecret:token.secret];

您应该分别将key&secret作为第一和第二参数传递。

关于ios - 为什么保存Twitter ACAccount时出现此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12104976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com