Return to Snippet

Revision: 37666
at December 15, 2010 03:29 by visualidiot


Initial Code
<?php

if(isset($_GET['username'])) {

//	Retrieve the follower count
$xml = file_get_contents('http://api.twitter.com/1/users/show.xml?screen_name=' . $_GET['username']);

//	If the followers' count is not zero
if (preg_match('/followers_count>(.*)</', $xml, $match) != 0) {
	//	Your followers, minus Jesus'.
	$count = $match[1] - 12;

	//	If we've got more than 12.
	if($match[1] > 12) {
		echo 'Nice one, ' . $_GET['username'] . '! You have ' . $count . ' more followers than Jesus!';
	} else {
		echo 'Jesus has more followers than me.';
	}
}


} else {
?>

<form method="get" action="<?php echo $_SERVER['HTTP_REFERRER']; ?>">
	<input id="username" name="username" type="text" value="What's your Twitter username?" />
	<input type="submit" value="Let's rock!" />
</form>
<?php

}


?>

Initial URL
http://vidmarkr.com/twitter.php

Initial Description
Checks your follower account against 12.

Initial Title
Do I have more followers than Jesus?

Initial Tags


Initial Language
PHP