我在創建和保存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.
失敗)
有關這個主題的任何指導,將不勝感激!
謝謝。