欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP cURL AJAX 代理问题

程序员文章站 2022-06-16 18:13:41
...
执行一次时是正常的,短时间(小于一秒)内连续请求多次就会出现只能成功执行一条请求,后面的请求就会报错说未收到回应或者收到多条相同的回应,可执行代码测试。

代码如下:

PHP

HTML


Get Weather

name id main description icon

回复内容:

执行一次时是正常的,短时间(小于一秒)内连续请求多次就会出现只能成功执行一条请求,后面的请求就会报错说未收到回应或者收到多条相同的回应,可执行代码测试。

代码如下:

PHP

HTML


Get Weather

name id main description icon

我觉得应该是API这边做了限制,请看OpenWeatherMap API官网上写的:

How to work with us effectively

These are several recommendations how to work with our free service in more effective way:

  • Do not send requests more then 1 time per 10 minutes from one device.The weather is changing not so frequently as usual.
  • Use the name of the server as api.openweathermap.org. Please never use the IP of the server.
  • If possible please use city ID or city name instead of city coordinates. It is let us use cash server more effective.
  • The service is absolutely free and has some limitation of capacity. So if you do not get respond from server please do not try to repeat your request immediately, please repeat it in 10 min. Also please store your previous request data.
  • If you need secured SLA please contact us.

以及价目表上的情况,明确表明API有频率限制了。而且是申请了API的情况下。像你这样直接就抓接口的人肯定有很多,也就是共用一个接口的人很多,所以更甚。所以正确的做法是去老老实实的申请一个Key啦,然后按照倒数第二条写的一样,按照规定频率去做查询然后存储数据,自己网站这边访问只需要读取存储好的数据就好啦。

相关标签: php curl