Twitter follower count api in javascript/jquery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>

function getTwitterFollowerCount(username, callback) {
$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D'http%3A%2F%2Ftwitter.com%2F" + username + "'%20and%20xpath%3D'%2F%2Finput%5B%40id%3D%22init-data%22%5D'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys", function (data) {
callback(data.query.results.input.value.match(/followers_count":(\d+)/)[1]);
});
}


getTwitterFollowerCount('coding_4_devs', function (count) {
$('#follower-count').html("<h2>Twitter Followers Count: "+count+"</h2>")
});

</script>

<div id="follower-count">
<h2>Loading...</h2>
</div>

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *