読者です 読者をやめる 読者になる 読者になる

Google CGI API for Japanese Input

WebService::Simpleを使ってGoogle CGI API for Japanese Input - アリ より
こう書けよ。

use strict;
use warnings;
use Encode;
use JSON;
use LWP::UserAgent;
use URI;
use Data::Dumper;
use Data::Recursive::Encode;

my $text = shift or die;

my $uri = URI->new('http://www.google.com/transliterate');
$uri->query_form(langpair => 'ja-Hira|ja', text => $text);

my $ua = LWP::UserAgent->new();
my $res = $ua->get($uri);
my $json = $res->content;
my $content = JSON->new->relaxed(1)->decode($json);

warn Dumper(Data::Recursive::Encode->encode_utf8($content));