Member Panel

How To Display Twitter Followers As Text
February 9th, 2012 - 11 Comments »

 

In a previous post I showed you to display your Feedburner Subscriber count as text, now here is the code to display your twitter followers as text.

Step 1

Create a new file in your chosen code editor and copy and paste the following code into the file:

Where on line 5 it says “handyHTML” change that to your Twitter User. Once that is done save the file as twitter-count.php, save the file into the root of your websites directory.

Step 2

Now copy and paste the following code where you want the count to display, this calls the twitter-count.php file we created in Step 1 and outputs the total followers of the specified Twitter account.

Step 3

Finally you can style your Twitter count, here is an example:

HTML

CSS

 

…and voila! Come across any problems, comment and one of us will assist you.

Related posts:

 

 

11 Responses

  1. Raj says:

    This is the exact thing I am searching for last few hours.. the next thing I need to figure out is a way to display FB Likes as text.

  2. Hi Raj!

    Try this http://www.handy-html.com/another-simpler-way-to-display-facebook-fan-count-as-text/ this shows the number of “likes” or fans a Facebook page has.

    Thanks.

    George

  3. Tom says:

    Hi,

    Great tutorial!
    It’s all set up correctly. How long time will it take before Twitter responds? Because nothing is showing now.

    Thanks!

    // Tom

  4. Hi Tom,

    Apologies, the PHP include path was wrong, I have just updated the code above.

    Let me know if you have anymore problems.

    George

  5. Tom says:

    Thanks! It works fine now.

    I want to add several counts on to my page. I’m about to make a table of fifteen (15) different account. How can I do that?

  6. Hi Tom,

    Off of the top of my head one way would be to make 15 files or however many accounts you want to use and just name them seperate to each account. (twitter-1.php, twitter-2.php, twitter-3.php and so on). Each file having its own account details in.

    Then simply include each file where you want each count to display.

    Note: this may not be best practice way to do this, although it will definately work. No matter what way you do it you’ll have to make 15 calls to twitter to get each accounts count anyways…

    Hope this helps.

    George

  7. Ayushi says:

    Hi,

    I am getting an error which says

    Fatal error: Call to undefined function get_option() in /home/wwwlinu/public_html/theplayers/inversore/twitter-count.php on line 2

    Please let me know what is missing in my code.

  8. santosh says:

    this works but i am searching for a method, so that twitter follower is shown within the twitter button….

  9. Alex Thomas says:

    Twitter have change the URL for the api, change the following:

    $xml=file_get_contents(‘http://twitter.com/users/show.xml?screen_name=handyHTML’);

    to:

    $xml=file_get_contents(‘http://api.twitter.com/users/handyHTML’);

    Al

Leave a Reply