Skip to content

Instantly share code, notes, and snippets.

@n1k0
Created May 15, 2010 19:58
Show Gist options
  • Save n1k0/402376 to your computer and use it in GitHub Desktop.
Save n1k0/402376 to your computer and use it in GitHub Desktop.
retrieves latest 100 tweets for a given search in the twitter timeline
<?php
$searchtag = '#plop';
$tweets = json_decode(file_get_contents('http://search.twitter.com/search.json?rpp=100&q='.urlencode($searchtag)));
foreach ($tweets->results as $tweet) {
echo sprintf("@%s: %s\n", $tweet->from_user, (string) $tweet->text);
}
<?php
$searchtag = '#plop';
$tweets = simplexml_load_string(file_get_contents('http://search.twitter.com/search.atom?rpp=100&q='.urlencode($searchtag)));
foreach ($tweets->entry as $tweet) {
echo sprintf("@%s: %s\n", $tweet->author->name, (string) $tweet->title);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment