I had the same problem- for me I had to enable the API in the google API 
manager.

https://console.developers.google.com/apis/credentials?project={your 
project - create this in the control panel for google custom search}

So even though I had a custom search engine id and a API key, the API was 
not enabled for some reason. Once I enabled it, the error 403 went away 
almost immediately.

Another possibility I found while searching for the solution is that you 
have IP blocking turned on in the API configuration (although this was not 
the case for me).

Peter

On Sunday, December 8, 2013 at 9:27:20 AM UTC-7, Ritter wrote:
>
> Hello,
>
> I am trying to search Google using Custom Search API with the following 
> Perl script. Strangely, the response with the script is [403 Forbidden] 
> while
> the same request over the GUI (Google APIs Explorer/CustomSearch 
> API/search.cse.list) pass through.
>
> Here is the script:
>
> #!/usr/bin/perl 
>
> use strict;
> use warnings;
> use WWW::Google::CustomSearch;
> use Data::Dumper;
>
> my $api_key = '{HERE_IS_MY_API_KEY}';
> my $cx      = '{MY_custom_search_engine_ID}';
> my $filter  = '0';
> my $country = 'de';
> my $engine  = WWW::Google::CustomSearch->new(cx => $cx, filter => $filter, 
> gl => $country, api_key => $api_key);
> #print Dumper(\$engine);
> my $result  = $engine->search('Linux');
> print Dumper(\$result);
> my $page    = $result->request;
> my $another = $page->fetch; 
>
> Comparing both search strings (search.cse.list and the one generated by my 
> script) are almost the same (apart from some additional parameters which
> are not relevant). The search strings are:
>
> *search.cse.list:*
>
> https://www.googleapis.com/customsearch/v1?q=Linux&cx={MY_custom_search_engine_ID}&filter=0&gl=de&num=10&safe=off&start=1&key={YOUR_API_KEY}
>
> *My Perl Script:*
>
> https://www.googleapis.com/customsearch/v1?key={HERE_IS_MY_API_KEY}&cx={MY_custom_search_engine_ID}&prettyprint=true&alt=json&safe=off&num=10&start=1&filter=0&q=Linux
>
> Any ideas what might be wrong and how to fix it?
>
> Best Regards,
>
> Ritter
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
To view this message on the web, visit
https://groups.google.com/d/msgid/google-ajax-search-api/999213c3-0aac-4439-9549-4f69322df9bb%40googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to