2
我試圖將一個Twitter帳戶保存到ACAccountStore
。爲什麼在保存Twitter ACAccount時出現此錯誤?
我使用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。
出了什麼問題?
不,它不是OAToken對象,我將令牌和祕密作爲NSString對象傳遞。無論如何,我會遇到同樣的問題,對吧? – emenegro
已更新的答案。 – msk
Arrrrrrghhhhhhh,我很愚蠢T_T我將'token'和'token'作爲參數傳遞,而不是'token'和'secret'。無論如何,這並沒有解決問題:-( – emenegro