2012-07-05 92 views
1

我正在嘗試使用NSURLConnection從Twitter獲取推文,並且我一直保持每小時(150)的最大請求數。我轉而使用經過驗證的方式獲取推文,如下所示,但仍然達到了最大的API調用 - 150.我如何能夠爲每個設備製作超過150個推文請求?Objective-C Twitter API 150請求

ACAccountStore *store = [[ACAccountStore alloc] init]; 
ACAccountType *twitterAccountType = 
[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 

// Request permission from the user to access the available Twitter accounts 
[store requestAccessToAccountsWithType:twitterAccountType 
       withCompletionHandler:^(BOOL granted, NSError *error) { 
        if (!granted) { 
         // The user rejected your request 
         NSLog(@"User rejected access to the account."); 
        } 
        else { 
         // Grab the available accounts 
         NSArray *twitterAccounts = 
         [store accountsWithAccountType:twitterAccountType]; 

         if ([twitterAccounts count] > 0) { 
          // Use the first account for simplicity 
          ACAccount *account = [twitterAccounts objectAtIndex:0]; 

          // Now make an authenticated request to our endpoint 
          NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; 
          [params setObject:@"1" forKey:@"include_entities"]; 

          // The endpoint that we wish to call 
          NSURL *url = 
          [NSURL 
           URLWithString:@"https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=%@&count=5",someTwitterUserName]; 

          // Build the request with our parameter 
          TWRequest *request = 
          [[TWRequest alloc] initWithURL:url 
               parameters:params 
               requestMethod:TWRequestMethodGET]; 

          // Attach the account object to this request 
          [request setAccount:account]; 

          [request performRequestWithHandler: 
           ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 
            if (!responseData) { 
             // inspect the contents of error 
             NSLog(@"%@", error); 
            } 
            else { 
             NSError *jsonError; 
             NSArray *timeline = 
             [NSJSONSerialization 
             JSONObjectWithData:responseData 
             options:NSJSONReadingMutableLeaves 
             error:&jsonError];    
             if (timeline) {       
              // at this point, we have an object that we can parse and grab tweet information from 
              NSLog(@"%@", timeline); 
             } 
             else { 
              // inspect the contents of jsonError 
              NSLog(@"%@", jsonError); 
             } 
            } 
           }]; 

         } // if ([twitterAccounts count] > 0) 
        } // if (granted) 
       }]; 
+0

極限嘗試看看他們是否在150有一個限度我敢肯定你不能。 –

+0

我想你的意思是'[NSURL URLWithString:[NSString stringWithFormat:@「https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=%@&count=5」,someTwitterUserName]] ' –

回答

0

這個帖子

solution

問題在你的Twitter的應用程序,誰擁有在默認

+0

錯誤:「超出速率限制,客戶每小時可能發出超過150個請求。」每個設備每小時可能發出超過150個請求,並且我想使超過150個。 –

+0

我的答案已更新 – CReaTuS