Introduction to Web Services with Perl


<  >  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21 

#!/usr/bin/perl
# Another test of the Google API

use strict;
use warnings;

use SOAP::Lite;

my $google_search = SOAP::Lite->service("file:./GoogleSearch.wsdl");

my $google_key='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

my $query = 'kw.pm.org';

my $results = $google_search -> 
	doGoogleSearch(
		$google_key, $query, 0, 10, "false", "",  "false",
		"", "latin1", "latin1"
	);

@{$results->{resultElements}} or exit;

foreach my $result (@{$results->{resultElements}}) {

	print
		join "\n",  
		$result->{title} || "no title",
		$result->{URL},
		$result->{snippet} || 'no snippet',
		"\n";
}