Skip to content

Instantly share code, notes, and snippets.

@Telltak
Created December 19, 2010 16:29
Show Gist options
  • Save Telltak/747453 to your computer and use it in GitHub Desktop.
Save Telltak/747453 to your computer and use it in GitHub Desktop.
<html><body>
<?php
function best_tweet($user){
$tweet_score=0;
$tweett="";
foreach ($user->tweets as $tweet){
if ($tweet->xp_value>$tweet_score){
$tweett=json_decode(file_get_contents("http://api.twitter.com/1/statuses/show/".$tweet->tweet_id.".json"))->text;
$tweet_score=$tweet->xp_value;
}
}
return "$tweett<br>";
}
if (isset($_REQUEST['user1'])) {
$username=$_REQUEST['user1'];
$user1=json_decode(file_get_contents("http://cursebird.com/$username.json"));
print "$username, who swears like $user1->swears_like, has $user1->xp_value points and is level $user1->level!\n<br>";
print "$username's highest scoring tweet is:<br>";
print best_tweet($user1);
}
if (isset($_REQUEST['user2'])) {
$username2=$_REQUEST['user2'];
$user2=json_decode(file_get_contents("http://cursebird.com/$username2.json"));
print "<br>$username2, who swears like $user2->swears_like, has $user2->xp_value points and is level $user2->level!\n<br>";
print "$username2's highest scoring tweet is:<br>";
print best_tweet($user2);
if ($user1->xp_score > $user2->xp_score){
print "<br>$username beats $username2 by ".($user1->xp_score - $user2->xp_score);
}
else {
print "<br>$username2 beats $username by ".($user2->xp_score - $user1->xp_score);
}
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment