Twitter Badge
I created this Twitter badge for two primary reasons. The official Twitter badge can be slow to load sometimes or doesn’t load at all due to the API limit. The other reason is that I don’t want @replies shown in my stream. The script is written in PHP and uses local file storage to cache the tweets.
Here are the features of the badge:
- display up to 20 most recent tweets
- contact Twitter at a specific interval and cache the results in a file
- if Twitter is down, display most recently cached tweets
- does not count towards the visitor’s API limit
- option to hide @replies from the stream
- more accessible since it does not require JavaScript
Usage:
<div id="twitter-box">
<h2>Twitter</h2>
<ul id="twitter-updates"><?php include 'twitter_badge.php'; ?></ul>
</div>
or with jQuery:
$(document).ready(function(){
$('#twitter-updates').load('twitter_badge.php');
});
... elsewhere
<div id="twitter-box">
<h2>Twitter</h2>
<ul id="twitter-updates"><li>Loading tweets...</li></ul>
</div>
