Created
December 28, 2010 20:55
-
-
Save chrismytton/757700 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* Simple twitter stream function | |
* | |
* Usage: $tweets = userTimeline("hecticjeff"); | |
*/ | |
function userTimeline($screenName) | |
{ | |
// Create a remote connection | |
$twitter = curl_init("http://api.twitter.com/1/statuses/user_timeline.json?screen_name={$screenName}"); | |
// Tell curl to return the body of the response | |
curl_setopt($twitter, CURLOPT_RETURNTRANSFER, true); | |
// Execute the request | |
$response = curl_exec($twitter); | |
// Decode the results | |
return json_decode($response); | |
} |
This file contains 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
<?php | |
// Loop over tweets | |
foreach (userTimeline("hecticjeff") as $tweet) { | |
echo $tweet->text . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment