-1

悪い認証エラーが発生するたびに、REST api 1.1 を使用して Twitter フォロワーを取得しようとしています。Twitter の開発者ブログとドキュメントからほぼすべてのドキュメントを読みましたが、認証されたリクエストを Twitter REST API に送信する方法がわかりません。誰かが Twitter auth のサンプル コードを持っている場合は、私たちと共有してください。

どんな助けでも大歓迎です。

NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/followers.json"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setValue:[@"OAuth oauth_consumer_key=***************,oauth_nonce=*****************, oauth_signature=******************,oauth_signature_method=HMAC-SHA1, oauth_timestamp=1371709719,oauth_token=*****************, oauth_version=1.0" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]forKey:@"Authorization"];

TWRequest *twRequest = [[TWRequest alloc]initWithURL:url parameters:dict requestMethod:TWRequestMethodPOST];

[twRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
     NSLog(@"Response error: %@", error);
    NSMutableDictionary *responseDictionary  = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil];
    NSLog(@"Response dictionary: %@", responseDictionary);
}];
4

1 に答える 1