Cached Twitter Follower Count
The following WordPress snippets will cached Twitter follower count
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function get_follower_Count(){ $count = get_transient('follower_count'); if ($count !== false) return $count; $count = 0; $data = wp_remote_get('http://api.twitter.com/1/users/show.json?screen_name=YOURNAME'); if (!is_wp_error($data)) { $value = json_decode($data['body'],true); $count = $value['followers_count']; } set_transient('follower_count', $count, 60*60); // 1 hour cache return $count; } |
Add the first section of code to the functions.php