Posted By

visualidiot on 12/15/10


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

courtzie
vehler


Do I have more followers than Jesus?


 / Published in: PHP
 

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

Checks your follower account against 12.

  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. ?>

Report this snippet  

You need to login to post a comment.