Skip Menu |

This queue is for tickets about the WWW-Google-CustomSearch CPAN distribution.

Report information
The Basics
Id: 101571
Status: resolved
Priority: 0/
Queue: WWW-Google-CustomSearch

People
Owner: MANWAR [...] cpan.org
Requestors: xedivad [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.24
Fixed in: 0.25



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; }
Hi, Thanks for reporting the issue. I wonder where you got that code from. As per the perldoc of package WWW::Google::CustomSearch::Item, it should be something like below: use strict; use warnings; use WWW::Google::CustomSearch; my $api_key = 'Your_API_Key'; my $cx = 'Search_Engine_Identifier'; my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); my $result = $engine->search("Google"); foreach my $item (@{$result->items}) { print "Item Snippet: ", $item->snippet, "\n" if defined $item->snippet; } The only difference between what is documented and yours is the following line: foreach my $item (@{$result->items}) { The $result->items returns ref to a list of items. You script returns the expected result once I changed the above line. Please give it a go. If you still have trouble then please don't hesitate to shout back. Best Regards, Mohammad S Anwar
From: xedivad [...] gmail.com
Thank you for the quick answer. However, as I expected, nothing changes, since the problems occurs on the line the call the search API, that is: my $result = $engine->search("Google"); Running your script I get: WWW::Google::CustomSearch::search(): request to API failed (status: 599) file g.pl on line 8 where line 8 is the line above where search() is called. I would not have submitted the bug if I was not sure that cx and api_key are ok. And they are, because using them when calling googleapis url works. Until about one year ago the same code worked perfectly. Now you confirm that using my cx and api_key the script works, right ? So I wonder what could be the reason for that call failure.
Hi, I just noticed that OS is Darwin. If I am not mistaken it is Apple OS, correct? Unfortunately I don't have box with Darwin so can't replicate the issue. As I said earlier your script works with one line changes on my ubuntu box. I reckon, Darwin is not happy with something or the other. I will try to find someone with Darwin box to investigate this further. Please accept my apology for any inconvenience. Best Regards, Mohammad S Anwar
From: xedivad [...] gmail.com
Hi I contacted another person with macosx who solved the issue by installing IO::Socket::SSL This was required since the apis are accessed via https. Probably this is a missing dependence that should be added to WWW::Google::CustomSearch, but most users don't have this problem because they install before other modules that provide SSL, while I installed CustomSearch as first module. Hope this help other people using the module, thank you again for your help. Il Sab 17 Gen 2015 06:32:32, MANWAR ha scritto: Show quoted text
> Hi, > > I just noticed that OS is Darwin. If I am not mistaken it is Apple OS, > correct? > Unfortunately I don't have box with Darwin so can't replicate the > issue. As I said earlier your script works with one line changes on my > ubuntu box. > > I reckon, Darwin is not happy with something or the other. I will try > to find someone with Darwin box to investigate this further. > > Please accept my apology for any inconvenience. > > Best Regards, > Mohammad S Anwar
Hi, Just pushed WWW::Google::CustomSearch v0.25 with the patch. Below is the link to GitHub repository: https://github.com/Manwar/WWW-Google-CustomSearch/commits?author=Manwar Many Thanks. Best Regards, Mohammad S Anwar