Blog Archives

Twitter Followers Count

php
function tcount( $username, $field, $display = false ) {
$interval = 3600;
$cache = get_option('tcount');
$url = 'http://api.twitter.com/1/users/show.json?screen_name='.urlencode($username);
if ( false == $cache )
$cache = array();
if ( !isset( $cache[$username][$field] ) ) {
$cache[$username][$field] = NULL;
$cache[$username]['lastcheck'] = 0;
}
if( $cache[$username]['lastcheck'] $value)
if( isset($data->$key) )
$cache[$username][$key] = $data->$key;
$cache[$username]['lastcheck'] = time();
}
else {
$cache[$username]['lastcheck'] = time()+60;
}
update_option( 'tcount , $cache );
}
if ( false != $display )
echo $cache[$username][$field];
return $cache[$username][$field];
}
?>

To Display Twitter Count Use Code Below

echo tcount(“Your_twitter_user_name”,”followers_count”);

 

Design a site like this with WordPress.com
Get started