Jump to content

Twitter Cache?


indie

Recommended Posts

Does anyone know how to cache Tweets as to not reach the API rate limit? I am using the Twitter-provided widget to display multiple profiles on a website, but the API hits the limit of 150 per hour. Is there any way to cache the Tweets and still use this widget? Or does anyone know of a good widget that caches, or simple code?

 

If anyone knows, please explain in newbie terms.

 

Thanks a lot!

Link to comment
Share on other sites

have you thought to use twitter cache  and JSON:confused:

 

 

http://mark.koli.ch/twittercacher/TwitterCacher.phps

http://mark.koli.ch/twittercacher/JSON.phps

example:

<?php

require_once("JSON.php");
require_once("TwitterCacher.php");

$twEmail = "you@example.com";
$twPass = "password";

$json = new Services_JSON();
$tc = new TwitterCacher($twEmail,$twPass);

// I do this just to be a nice guy. So Twitter knows who we are.
$tc->setUserAgent("Mozilla/5.0 (compatible; TwitterCacher/1.0;)");

// Read the timeline from the cache, or from Twitter.
$timeline = $json->decode( $tc->getUserTimeline() );

foreach( $timeline as $tweet ) {

  // Get the Tweet itself.
  $text = $tweet->text;

  // Twitter uses GMT+0 but I convert it to my local time.
  $date = date('M j, Y @ h:i A', strtotime($tweet->created_at));

  echo $text . "<br />" . $date . "<hr />";

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.