Skip to content

Conversation

@rodrigopolo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant