Do I have more followers than Jesus?


/ Published in: PHP
Save to your folder(s)

Checks your follower account against 12.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. if(isset($_GET['username'])) {
  4.  
  5. // Retrieve the follower count
  6. $xml = file_get_contents('http://api.twitter.com/1/users/show.xml?screen_name=' . $_GET['username']);
  7.  
  8. // If the followers' count is not zero
  9. if (preg_match('/followers_count>(.*)</', $xml, $match) != 0) {
  10. // Your followers, minus Jesus'.
  11. $count = $match[1] - 12;
  12.  
  13. // If we've got more than 12.
  14. if($match[1] > 12) {
  15. echo 'Nice one, ' . $_GET['username'] . '! You have ' . $count . ' more followers than Jesus!';
  16. } else {
  17. echo 'Jesus has more followers than me.';
  18. }
  19. }
  20.  
  21.  
  22. } else {
  23. ?>
  24.  
  25. <form method="get" action="<?php echo $_SERVER['HTTP_REFERRER']; ?>">
  26. <input id="username" name="username" type="text" value="What's your Twitter username?" />
  27. <input type="submit" value="Let's rock!" />
  28. </form>
  29. <?php
  30.  
  31. }
  32.  
  33.  
  34. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.