All,
I’m hitting a rate limit all the time. I’m just trying to pull the latest status from my own timeline. I’m using the following code to make that happen:
$url = "https://api.twitter.com/1/statuses/user_timeline.json?screen_name={$username}&count={$how_many}";
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
$contents = curl_exec( $curl );
curl_close( $curl );
if ( ! empty( $contents ) ) {
// Decode it.
$tweet = json_decode( $contents );
// Cache it for next time.
set_transient( $id.'-'.$username, $tweet, 60*60*12 ); // 3 hour cache
}
This works fine but I hit my rate limit of 150 requests per hour all the time. I’ve read that if I authenticate to the API the rate limit is lifted. Can anyone explain how to do that?
Thanks in advance!
Do you need to be refreshing your status more than every 4 minutes? I would be guessing not, you’re actually setting a 3 hour cache in your code so why not use it?
Obviously you can reduce how long the cache lasts if you need to.