Subject: | request to API failed |
perl -v:
------------------------------------
perl 5, version 16, subversion 3 (v5.16.3) built for darwin-thread-multi-2level
uname -a:
------------------------------------
Darwin turing.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
PROBLEM
------------------------------------
Executing the attached g.pl file to search for a simple string returns:
WWW::Google::CustomSearch::search(): request to API failed (status: 599) file g.pl on line 7
Note that the problem is not related to the cx and api_key values, since invoking directly:
curl "https://www.googleapis.com/customsearch/v1?key=AIzaSyDnbGDj-YLsNcSiJx9Xt05wKx4hWFrB7TU&cx=002983251636507551537:yl9ytavmumm&q=Singapore&filter=1&start=1&num=10&alt=json"
works perfectly.
Subject: | g.pl |
use strict; use warnings;
use WWW::Google::CustomSearch;
my $api_key = 'AIzaSyDnbGDj-YLsNcSiJx9Xt05wKx4hWFrB7TU';
my $cx = '002983251636507551537:yl9ytavmumm';
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
my $result = $engine->search("Pollo");
print "Formatted Total Results: ", $result->formattedTotalResults, "\n";
my $page = $result->nextPage;
print "Title: ", $page->title, "\n";
foreach my $item ($result->items) {
print "Item Snippet: ", $item->snippet, "\n" if defined $item->snippet;
}