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
https://forums.phpfreaks.com/topic/246001-twitter-cache/
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 = "[email protected]";
$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
https://forums.phpfreaks.com/topic/246001-twitter-cache/#findComment-1263674
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.