Amazon APIの呼び出し
試しにPerlで書いてみた。
#!/usr/bin/perl # amazon.pl # A typical Amazon Web API Perl script that uses the SOAP::Lite Module. # Usage: perl amazon.pl <keyword> #Your Amazon developer's token my $dev_token='XXXXXXXXXXXXXXXXXXX'; ##my $dev_token='insert developer token'; #Your Amazon affiliate code my $af_tag='**************'; #Location of the Amazon WSDL file my $amazon_wdsl = "http://soap.amazon.com/schemas2/AmazonWebServices.wsdl"; use strict; #Use the SOAP::Lite Perl module use SOAP::Lite; #Take the query from the command-line my $keyword =shift @ARGV or die "Usage:perl amazon.pl <keyword>\n"; #Create a new SOAP::Lite instance, feeding it Amazon's WSDL my $amazon_search = SOAP::Lite->service("$amazon_wdsl"); #Query Amazon my $results = $amazon_search -> KeywordSearchRequest(SOAP::Data->name("KeywordSearchRequest") ->type("KeywordRequest") ->value(\SOAP::Data->value( SOAP::Data->name("keyword" => $keyword), SOAP::Data->name("page" => "1"), SOAP::Data->name("mode" => "books"), SOAP::Data->name("tag" => $af_tag), SOAP::Data->name("type" => "lite"), SOAP::Data->name("devtag" => $dev_token) )) ); foreach my $result (@{$results->{Details}}){ #Print out the main bits of each result print $result->{ProductName}|| "no title", "\nby ", join (', ', @{$result->{Authors}}), "\n$result->{OurPrice}", "\nASIN: $result->{Asin}", "\n\n"; }