twitter-php
twitter-php copied to clipboard
Added headers methods, and RAW data var
Some times you need to know your rate limiting, and the only way to know it is by reading this HTTP headers:
x-rate-limit-limit
x-rate-limit-reset
x-rate-limit-remaining
So I added the method _setHeader
to store the CURL received headers, and the getHeaderArray
method to return an indexed array with the current HTTP headers after any request:
$my_headers = $twitter->getHeaderArray();
$current_time = time();
$time_to_next = $my_headers['x-rate-limit-reset'] - $current_time;
if($tw_headers['x-rate-limit-remaining']<1){
echo "Sleeping for ".$time_to_next." seconds, or ".($time_to_next/60)." minutes .\n";
sleep($time_to_next);
}
I also added the public instance of the RAW body, for development and debugging purposes.