In previous post I have explined about getting the Facebook page details using Graph API and PHP. Now this post is about to get the Twitter Follower Count using PHP.
For this method what you will need is just and User Name of the Twitter Account. For Example Expert Developer’s Twitter Account is XpertDevelopers.
How it Works
Like Facebook Graph API, you just make one call to twitter URL using you twitter account name. So our twitter account is XpertDevelopers, then that URL will be http://twitter.com/users/show/XpertDevelopers
You will need to get the content of this URL and have to parse the content to get the Follower Count. Let’s see how to get this done with example.
$response = file_get_contents ( $url );
$t_profile = new SimpleXMLElement ( $response );
$count = $t_profile->followers_count;
echo "Expert Developer Twitter Followers : ".$count;
// Output
Expert Developer Twitter Followers : 73