Created
July 27, 2012 00:59
-
-
Save dfkoz/3185519 to your computer and use it in GitHub Desktop.
Simple PHP Code to Query Twitter Search API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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