Blogger Ever

Get Twitter followers in plain text using jQuery, pure client-side method in Twitter API v1.1

Gain twitter count and display in plain text using pure client-side method of jQuery in Twitter API v1.1
Get Twitter followers in plain text using jQuery, pure client-side method in Twitter API v1.1

Social following counter is now popular among industry because companies and blogs with high social following likes to display their followers count in their blogs. Since,Tuesday, May 7, 2013 Twitter closed its API v1, since then it is not possible to get Twitter followers count and many other data through any client-side method. So,  in this post I'll tell that how to get followers count using Twitter Counter,  it is a third party application which have its own API.So lets begin with it.
As always, the first rule to access any API is to first signup and then to get an API key. So first go to Twitter Counter and sign up with any Twitter account. Actually, it is one of the best source to get in detail stats of your Twitter account, hence you can analyse your Twitter activity more conveniently. So lets back on our topic.
  • First go to Twitter Counter and sign up with any Twitter account.
  • Then go to API Documentation page. Here you will find every related document about their API. If you will notice, then you will require API key to access their data, so just click on green button on right top side, Request an API key.
  • Fill up the form with correct information, after submission you will receive your API key on your e-mail.
The limit of sending requests in 100 requests per hour per user, but if you want more then you just simply contact and describe your reason. For favorable reasons, they might increase up your limit. Now you have your API key, now you want is Twitter user ID to access the data. Its not username but user ID. For user ID go to Get a User's Twitter ID and just simply write your username and in return your user ID will return.

Request your data

URL: http://api.twittercounter.com/?apikey=e9335031a759f251ee9b4e2e6634e1c5&twitter_id=15160529&output=JSONP&callback=getcount

The easiest way to get data is send a GET request via AJAX jQuery and get data in return.So this is how you will send your AJAX request:

HTML

<script src='jquery.js' type='text/javascript'/>
<script src='twittercount.js' type='text/javascript'/>
<span class='twittercount'></span>

jQuery (twittercount.js) 

$.ajax({
    type: "GET",
    dataType: "jsonp",
    url: "http://api.twittercounter.com/?twitter_id=USER_ID&apikey=YOUR_API_KEY&output=JSONP&callback=getcount",
    success: function (data) {
        var twitterfollowcount = data.followers_current;
        $(".twittercount").html(twitterfollowcount);
    }
});
Replace your USER_ID and YOUR_API_KEY. Do not forget to add jQuery in your script.
Blogger

2013-2016 Copyright Blogger E\ver . Coded, managed and founded by Mohammad Hamza (@hamzadhamiya) . Hosted on Blogger and fonts used are Raleway and Open Sans.