XF 2.2 Twitter Widget

btmgreg

Well-known member
Hi guys,

I'm trying to achieve the following -

A widget that literally just displays the follower count for my twitter handle.

I've found the following code, but no idea where to call the .PHP file in order to display this.

Code:
<?php
     $twitterid = "globinch";
     $stringVal="";
     $url="http://twitter.com/users/show.xml?screen_name="; 
     $url= $url. $twitterid;
     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_URL, $url); 
     $data = curl_exec($ch); 
 
     curl_close($ch); 
     $xml = new SimpleXMLElement($data);
     $followers = $xml->followers_count;
     echo "<div style='color:red;font-size: 14px;font-weight: bold;line-height: 15px;'>" . $followers ." : Twitter Followers Today" . "</div>";
     // The above $followers value can be displayed any where in the page below the above code using echo. Eg.:echo $followers ;
?>

Looking similar to this -

1608488874408.webp

The the entire text linking to the @ twitter handle.

I'm keen to learn how to do this, so was hoping for some tips! Many thanks
 
Top Bottom