简体   繁体   中英

How to revoke twitter API request after rate limit exceed?

I am working with Twitter API 1.1 and I am fetching tweets of a user.

I am using this code

<?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>';
 ?>

Is there way to recieve since_id after a particualr request so that I can requeue my function for the next request starting from the last recieved id?

For Example: In a single request I am fetching 0-1000 records, On my next request I want start from 1001th record.

Is it possible in twitter?

If you made a request to a timeline without using since_id, and the most recent tweet you got back had the ID "123" then, after an interval, you can use that most recent tweet ID "123" as your since_id value to user_timeline. You would then get (up to 200) of the next most recent tweets posted by that user "since" they posted tweet "123".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM