Skip to content

Instantly share code, notes, and snippets.

@dfkoz
Created July 27, 2012 00:59
Show Gist options
  • Select an option

  • Save dfkoz/3185519 to your computer and use it in GitHub Desktop.

Select an option

Save dfkoz/3185519 to your computer and use it in GitHub Desktop.
Simple PHP Code to Query Twitter Search API
// This address links to the Twitter search API, and asks for tweets related to tacos
$tweet_url = “http://search.twitter.com/search.json?q=tacos&rpp=100&include_entities=true&result_type=recent&geocode=40.7142,-74.0064,25mi&since_id=$since_id”;
// Load the Twitter API results into a variable
$json_response = file_get_contents($tweet_url);
// Decode the raw data into a form usable by PHP
$parsed = json_decode($json_response);
// Print out the text of each tweet
foreach($parsed->results as $tweet) {
echo $tweet->text;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment