2013-06-20 319 views
-1

我一直試圖讓Twitter的追隨者使用REST API 1.1每次我得到錯誤的身份驗證錯誤。我已經閱讀了Twitters開發者博客和文檔中的幾乎所有文檔,但沒有得到如何向Twitter REST API發送授權請求。如果有人有任何Twitter驗證示例代碼,請使用解析Twitter帳戶登錄,請與我們分享。Twitter REST API 1.1身份驗證問題

任何幫助將不勝感激。

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); 
}]; 
+0

發佈您的代碼,你已經嘗試 – Venkat

+0

請檢查源代碼更新的問題。 –

回答

0

查看STTwitter庫。

下面是一個示例調用,這樣就可以看到它的樣子:

[twitter getHomeTimelineSinceID:nil count:@"20" successBlock:^(NSArray *statuses) { 
    // ... 
} errorBlock:^(NSError *error) { 
    // ... 
}];