The usefulness of displaying the number of followers also varies, apart from personal statistics, displaying the number of followers is also to make others believe that the website is serious, so it is not uncommon for many people to use the services of a certain person/company to increase the number of followers (we do not will discuss that here).
Previously, tutorial-webdesign.com also discussed how to display the Twitter timeline on a website page, this trick can be combined if needed.
Image credit: Lakeshorebranding.com
Okay, straight to the topic, here we will use PHP to display the number of followers. Enough with just 4 lines of PHP code.
Create a file with the name twitter_followers_count.php , and fill it as follows
$twitter_id = “tut_web”;
$url = “http://twitter.com/users/show/$twitter_id”;
$response = file_get_contents ( $url );
$count = 0;
$t_profile = new SimpleXMLElement ( $response );
$count = $t_profile->followers_count;
To display it on the web page, simply print it as usual.
If you want, you can create a special method/function to make it easier to call.
The results that will appear are as follows
Here the results we have designed a little, but are not explained in the tutorial because it is too long because the point is what is written in this tutorial. But can be downloaded if you want to see.