简体   繁体   中英

dailyLimitExceededUnreg error with key set in request

I have 3 server keys in my google console for different servers.

In the beginning only one key seemed to work, and that was my local IP address.

After debugging with cURL on the staging server I found that the response was:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}

This didn't really make sense to me, because the key was provided and the key was definitely set with the appropriate IP address.

So I started the debugging process and for the staging server I tried some cURL IP discovery tools.

Suddenly icanhazip.com gave me the IPv6 address to my server, after adding this to the Allowed IP list it suddenly worked. Some weird behavior if you ask me.

So I still had my Production server to fix, and I found out that this one doesn't have an IPv6 address. The same tool returns the IPv4 address for me and in my control panel I also didn't set up an IPv6 address.

As google doesn't have a big support platform, I'm hoping someone here has ran into the same problem.

I'm trying to use google's custom search API.

Apparently I was using cURL in the wrong way on my server. It now works like a charm!

(Had to add apostrophes around the URL)

If everything else fails, you could just scrape a google search page and parse the results? Something like this (PHP):

$ch = curl_init ('');

$query = 'Pepijn';

curl_setopt ($ch, CURLOPT_URL, 'http://www.google.com/search?hl=en&tbo=d&site=&source=hp&q='.$query);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$output = curl_exec($ch);
curl_close($ch);

echo $output;

You would need to "sort" through all the returned html and all, but the results are basically in the list items in #search ol.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM