Revision: 42696
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 9, 2011 06:56 by ericmuyser
Initial Code
<? function ago($timestamp){ $difference = time() - $timestamp; if($difference < 60) return $difference." seconds ago"; else{ $difference = round($difference / 60); if($difference < 60) return $difference." minutes ago"; else{ $difference = round($difference / 60); if($difference < 24) return $difference." hours ago"; else{ $difference = round($difference / 24); if($difference < 7) return $difference." days ago"; else{ $difference = round($difference / 7); return $difference." weeks ago"; } } } } } $username = "username here"; $format='json'; // set format $tweets=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}")); // get tweets and decode them into a variable $tweet_count = 10; ?> <h5>LATEST TWEET<? if($tweet_count): ?>S<? endif ?></h5> <? foreach(array_slice($tweets, 0, $tweet_count) as $tweet): $time = ago(strtotime($tweet->created_at)); $content = $tweet->text; // show latest tweet //<a href="http://twitter.com/#!/status/username/39762213950459904"> ?> <small><?= $time ?></a></small> <p><?= $content ?></p> <? endforeach ?>
Initial URL
Initial Description
Initial Title
Output latest 10 tweets
Initial Tags
php
Initial Language
PHP