2015-06-16 142 views
0

我正在使用Twitter API 1.1,並且正在獲取用戶的推文。如何在費率限制超過後撤銷Twitter API請求?

我使用此代碼

<?php 
     $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; 
     $requestMethod = "GET"; 
     $cursor = isset($cursor) ? $cursor : "-1"; 
     $getfield = "?cursor=" . $cursor . "&user_id=" . $user . "&count=10"; 
     $twitter = new TwitterAPIExchange($settings);    
     $string = $twitter->setGetfield($getfield) 
       ->buildOauth($url, $requestMethod) 
       ->performRequest(); 
     $tweets = json_decode($string, 1); 
     echo '<pre>';print_r($string);echo '</pre>'; 
?> 

是否有particualr請求,這樣我就可以重新排隊我的函數從最後收到的ID開始下一個請求後才能收到since_id方式?

例如:在一個請求中,我獲取0-1000條記錄,在我的下一個請求中,我希望從第1001條記錄開始。

這是可能在推特?

回答

0

如果您在不使用since_id的情況下向時間軸發出請求,並且您最近收到的tweet的ID爲「123」,則在間隔後您可以使用最新的tweet ID「123」作爲您的since_id值給user_timeline。然後,您將獲得(最多200)該用戶發佈的下一個最新推文,因爲他們發佈了推文「123」。