Skip to content

Instantly share code, notes, and snippets.

@halka
Created April 8, 2009 10:28
Show Gist options
  • Save halka/91714 to your computer and use it in GitHub Desktop.
Save halka/91714 to your computer and use it in GitHub Desktop.
twitter updates viewing from windows command prompt
<?php
$user=NULL;
while(1){
echo "command exit -> :q\n";
echo 'username : ';
$fp=fopen("php://stdin","r");
$user=trim(fgets($fp,64));
fclose($fp);
if($user===':q') break;
echo "20*n n=";
$fp=fopen("php://stdin","r");
$count=trim(fgets($fp,64));
fclose($fp);
$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']." ".mb_convert_encoding(strip_tags($nakami['source']),'SJIS','AUTO')."\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