Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 22nd, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. use JSON;
  2. use Encode;
  3.  
  4. if (@ARGV<1) { print "usage: $0 user_id [page]\n"; exit(0); }
  5.  
  6. my $url="http://twitter.com/statuses/user_timeline.json?id=$ARGV[0]";
  7. $url.="\\&page=$ARGV[1]" if ($ARGV[1]);
  8.  
  9. open(F,"wget $url -O -|");my $j=<F>;close(F);
  10.  
  11. my $j=~s/\\u([0-9a-f]{4})/u16u8($1)/egi;
  12. my $d=JSON::decode_json($j);
  13. foreach(@$d){
  14.     print "$_->{id} from $_->{source}\n";
  15.     print "$_->{created_at}\n";
  16.     print e8($_->{text})."\n\n";
  17. }
  18. sub e8{Encode::encode('utf8',$_[0])}
  19. sub u16u8{e8(Encode::decode('utf16be',pack('H*',$_[0])))}