1

OSX Mavericks 10.9 で Twitter の SLRequest を実行すると、 Twitter API リクエストに対してエラー コード 32 で「Could not authenticate you」が返されます。簡単なコード スニペットを以下に示します。

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {

    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
    ACAccount *account = [accountsArray lastObject];

    NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1.1/help/test.json"];
    SLRequest *r = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:url parameters:nil];
    r.account = account;

    [r performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        NSLog(@"%@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
        dispatch_semaphore_signal(semaphore);
    }];

}];

dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

私にとって奇妙なのは、このまったく同じコード スニペットが iOS でも問題なく動作することです。ACAccount は有効なようで、preparedURLRequest にはすべての OAuth HTTP ヘッダーがあるようです。何が問題なのかわかりません...何かアイデアはありますか?

4

2 に答える 2

0

どうやら、この URL は、質問の投稿の時点を除いて、HTTP または HTTPS にはもう存在しません。Twitter はエラー 32 で応答していましたが、これはおそらくバグです。

とにかく、すべてが他の URL で問題なく動作します。

于 2014-02-19T14:46:15.263 に答える
0

少し遅くなりましたが、https を指定する必要があります。:-) あなたの問題を解決するためにさらに必要かどうかはわかりません!

于 2014-02-11T20:10:17.347 に答える