Quick Tip: Twitter Followers Count on Your Website Using PHP

Posted July 22, 2009 @ 12:39pm by Phil

Using TwitterQuery, my lightweight Twitter API, this simple function looks up and returns the Twitter followers count of the specified user.

<?php
  require "TwitterQuery.class.php";

  function followers_count ($user_id)
  {
    $twitterQuery = new TwitterQuery();
    $results = $twitterQuery->query("users/show/{$user_id}");
    return $results["followers_count"];
  }
?>

Download Source: followers_count.php

Tags: PHP/MySQL, Quick Tip, Twitter, TwitterQuery, Webmasters Tips