2

Twitter にログインした後、ユーザー名やユーザー ID などの有用なデータを印刷できます。ただし、OAuth トークンは常に null です。どうすれば入手できますか?OAuth トークンをサーバーに送信して、ユーザーが実際に本人であることを確認できるようにする必要があります。

ACAccountStore* accountStore = [[ACAccountStore alloc] init];
ACAccountType* twitterType = [self.context.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore
    requestAccessToAccountsWithType:twitterType
    withCompletionHandler:^(BOOL isAllowed, NSError* error) {
        dispatch_sync(dispatch_get_main_queue(), ^(void) {
            if (isAllowed) {
                ACAccount* account = [[self.context.accountStore accountsWithAccountType:[self.context.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]] lastObject];
                NSLog(@"username = %@", account.username);
                NSLog(@"user_id = %@", [[account valueForKey:@"properties"] valueForKey:@"user_id"]);
                // ouath token is always null
                NSLog(@"oauth token = %@", account.credential.oauthToken);
            }
        });
    }
];

私はReverse Authが必要だと「思います」が、そのチュートリアルでは不思議なことに「ステップ 1」のコードが省略されていました。

4

1 に答える 1

0

逆認証を使用する必要があります。

最近、Sean Cook の TWReverseAuthを使用しましたが、非常にうまく機能しました。Vendorディレクトリ内の個々のファイルの ARC をオフにするように注意してください。

于 2013-03-30T03:12:18.823 に答える