Created
April 9, 2009 12:49
-
-
Save halka/92444 to your computer and use it in GitHub Desktop.
downloading user's log from twitter.
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 | |
//how 2 use | |
//only working on console. | |
//ex) $php5 filename.php username n | |
//n of count of post 20*n | |
//u can get user's post. | |
$user=$argv[1]; | |
$count=$argv[2]; | |
$f=false; | |
for($i=1;$i<=$count;$i++){ | |
$url="http://twitter.com/statuses/user_timeline/$user.json?page=$i"; | |
$file=@file_get_contents($url); | |
if($file){ | |
$temp=json_decode($file,true); | |
if(!$f){ | |
echo "name : ".mb_convert_encoding($temp[0]['user']['name'],'SJIS','AUTO')."\n"; | |
echo "location : ".mb_convert_encoding($temp[0]['user']['location'],'SJIS','AUTO')."\n"; | |
echo "description : ".mb_convert_encoding($temp[0]['user']['description'],'SJIS','AUTO')."\n"; | |
echo "followes : ".$temp[0]['user']['followers_count']."\n"; | |
echo "url : ".$temp[0]['user']['url']."\n\n"; | |
} | |
$f=true; | |
foreach($temp as $nakami){ | |
//echo $nakami['text']."\n"; | |
echo mb_convert_encoding($nakami['text'],"SJIS","UTF-8")."\n"; | |
//echo "(".date("Y/m/d H:i:s",strtotime($nakami['created_at'])+9*3600).")".$nakami['id']."\n\n"; | |
echo "(".$nakami['created_at'].") ".$nakami['id']." ".strip_tags($nakami['source'])."\n\n"; | |
} | |
} | |
else echo "unable to get\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment