Created
December 9, 2010 23:00
-
-
Save emad-elsaid/735471 to your computer and use it in GitHub Desktop.
Getting latest tweets using php
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
<?php | |
// getting the latest tweets | |
$tweets_json = file_get_contents("http://twitter.com/statuses/user_timeline/blaz_boy.json?callback=t&count=100"); | |
// trimming the retrieved text to be pure json for PHP | |
$tweets_json = substr($tweets_json, 2, strlen($tweets_json)-4); | |
// convert to array of objects | |
$object = json_decode($tweets_json); | |
// the final desired output | |
$text = ''; | |
// traverse through all the object array | |
foreach( $object as $o ) | |
$text = $text.$o->text."\r\n"; | |
// write output to file | |
file_put_contents( "output.txt", $text ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment