Skip to content

Instantly share code, notes, and snippets.

@charlestati
Created March 23, 2015 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlestati/36f8d16dd0a5783dc0aa to your computer and use it in GitHub Desktop.
Save charlestati/36f8d16dd0a5783dc0aa to your computer and use it in GitHub Desktop.
Get tweets from a hashtag
$ch = curl_init('http://search.twitter.com/search.atom?q=' . urlencode($hashtag));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$answer = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($answer);
foreach ($xml->entry as $entry) {
$id = $entry->id;
$tweet = trim($entry->title);
$author = trim($entry->author->name);
$time = strtotime($entry->published);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment