Google Weather API returns HTTP 403 Error

后端 未结 2 1208
借酒劲吻你
借酒劲吻你 2021-01-28 08:30

I use the Google weather API in my web site, and today I get an error that the API link doesn\'t return any data.

When I check the link directly I get an (Error 403).

2条回答
  •  北海茫月
    2021-01-28 08:54

    Every now and then the API stops working for short periods of time, the last days more often a 403 is trown. For my site, last night it happened 13 times. But the site tries immediately again and the second or third time, the data loads without problems. As the API is unofficial, not sure what’s causing the 403.

    Make sure you cache the data as the API will block your IP temporary when you make too much requests. In my case, I cache for 20 minutes and if no data can retrieved, the site will not try more than 10 times to reload the API. Once I forgot to turn caching on after debugging and as my site did many hundred requests (with every visitor), the IP was blocked within an hour. If a remember correct, the error was not a 403. Fortunately, the block lasts for less than a half day.

提交回复
热议问题