Pages: [1]   Go Down
Send this topic | Print
Author Topic: Show amount of twitter followers with php.  (Read 312 times)
kurse
Authority Member
****
Online Online

Posts: 559


please dont read this,its personal!


WWW
« on: August 18, 2009, 12:03:24 AM »

This php code will retrieve the number of twitter followers you have and show it on your page, very simples.

Place this code whereever you want to show the number:
JUST REPLACE YOUR_TWITTER_NAME with your twitter name.

Code:
<?php
function get_data($url) {
   
$ch = curl_init();
   
curl_setopt($ch, CURLOPT_URL, $url);
   
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
   
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   
curl_setopt($ch, CURLOPT_PORT, 80);
   
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
   
curl_setopt($ch, CURLOPT_HEADER, false);
   
curl_setopt($ch, CURLOPT_REFERER, $referer);
   
//curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
   
$document = curl_exec($ch);
   
curl_close($ch);
   return
$document;
}
$urlpage_data = get_data("http://www.twitter.com/YOUR_TWITTER_NAME");
preg_match_all('#<span id="follower_count" class="stats_count numeric">(.*?)</span>#is', $urlpage_data, $urlmatches);
echo
"You have ". $urlmatches[1][0] ." Twitter Followers";
?>
Logged



Hi! I’m a signature virus! Add me to your signature to help me spread.
spam me: ispamspot@gmail.com

Rapidshare Link Checker
jarfilli
Member
*
Offline Offline

Posts: 9


WWW
« Reply #1 on: October 18, 2009, 02:21:37 PM »

Quite cool piece of code. Worked perfectly
Logged

viccowface
Webmaster | Desarrollador PHP
Hyper-Active Member
***
Online Online

Posts: 164



WWW
« Reply #2 on: October 24, 2009, 02:47:32 AM »

excelent code... tnks

 afro
Logged

Pages: [1]   Go Up
Send this topic | Print
Jump to: