Google Weather API返回HTTP 403错误 [英] Google Weather API returns HTTP 403 Error

查看:135
本文介绍了Google Weather API返回HTTP 403错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站上使用Google weather API,今天却收到一个错误消息,该API链接未返回任何数据.

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.

当我直接检查链接时,我得到一个(错误403).

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

此处是链接.

任何人都可以告诉我一个解决方案,并为我提供该API的另一个链接吗?

Can anyone please tell me a solution for this and provide me another link for the API?

推荐答案

每隔一段时间,API就会在短时间内停止工作,最后几天通常会抛出403.对于我的网站,昨晚发生了13次.但是该站点立即再次尝试,第二次或第三次加载数据没有问题.由于该API是非官方的,因此不确定是什么原因导致了403.

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.

请确保您缓存数据,因为当您发出过多请求时,API会阻止您的IP临时访问.就我而言,我缓存了20分钟,如果无法检索到任何数据,则该站点将尝试不超过10次来重新加载API.一旦我忘记在调试后打开缓存,并且由于我的站点(每个访问者)发出数百个请求,则IP在一个小时内被阻塞.如果没有记错,则错误不是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.

这篇关于Google Weather API返回HTTP 403错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆