2011-11-22 3 views
1

iOS5에서 새 트위터 계정을 만들고 ACAccountStore에 저장하는 데 문제가 있습니다.iOS5에서 트위터 ACAccount를 생성하는 중 오류가 발생했습니다. NSURLErrorDomain 오류 -1012

계정을 초기화하는 모든 단계를 수행 한 후에 ACAccountStore'ssaveAccount:withCompletionHandler:NSURLErrorDomain error -1012을 반환합니다.

비슷한 문제가있는 사람이 있습니까?

아래 코드 샘플은 requestToken을 사용하여 ACAccountCrendential으로 초기화합니다. 이 객체는 OAuth을 완료 한 후 트위터로부터받은 토큰과 비밀로 초기화 된 OAToken (ShareKit 객체)입니다. 자격 증명을 사용하여

계정 유형은 인증을 지원하고 계정이 인증되지 않은 경우, 계정 인증 :

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 ReferencesaveAccount:withCompletionHandler: 시도 OAuth 자체를 수행 할 것을 제안이다 . 인증에 성공하면 계정이 저장됩니다. 그렇지 않으면 저장되지 않습니다.

사용자 이름/암호를 입력하여 사용자가 직접 서버를 인증 할 수있는 방법이 없기 때문에 매우 이상합니다.

나는 또한이 주제에 대한 모든 지침을 크게 감상 할 수

(NSURLErrorDomain error -1012. 실패했습니다) 같은 결과로, 내 응용 프로그램의 소비자 키 및 소비자 비밀로 ACAccountCredential를 초기화하려고!

감사합니다.

답변

2

ACAccount를 사용하여 트위터 계정을 추가 할 때도 동일한 문제가 발생합니다. 그러나 승인 된 OAuth 액세스 토큰과 액세스 토큰 비밀을 사용하여 ACAccount로 트위터 계정을 만들 수 있었지만 소비자 키와 소비자 비밀은 사용할 수 없었습니다. (dev.twitter.com/apps->Twitter->OAuth->OAuth 설정 -> 액세스 토큰 및 액세스 토큰 비밀) 즉, OAuth 라이브러리를 사용하여 인증 된 액세스 토큰 및 액세스 토큰 비밀을 가져와야 할 때 사용자가 트위터 계정을 추가하고 있습니다.

업데이트 : 트위터가 기존 계정을 iOS5 시스템 계정 here으로 마이그레이션하는 방법을 알 수 있습니다. 이 링크를 통해 ACAccount를 추가하는 가장 좋은 예가 나에게 제공되었습니다.

관련 문제