file_get_contents在之前工作时失败

时间:2016-03-11 00:49:17

标签: php api http-headers

我正在尝试访问Steam提供的多个json文件,以获取CSGO项目的市场价格。我正在使用第一个有效的file_get_contents:

$inventory = file_get_contents('http://steamcommunity.com/profiles/' . $steamprofile['steamid'] . '/inventory/json/730/2');

但是第二次开始没有工作:

$marketString = file_get_contents('http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=' . urlencode($json_a->{'rgDescriptions'}->$rgDescrId->{'market_hash_name'}));

但是我收到了所有项目的错误,例如:

  

警告:file_get_contents(http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=Negev%20|%20Nuclear%20Waste%20(Minimal%20Wear)):无法打开流:HTTP请求失败!第24行/home4/matt500b/public_html/themooliecommunity.com/CSGO/index.php中的HTTP / 1.0 429未知

我可以确认allow_url_fopen已开启

将以下网址粘贴到浏览器中会显示网址

http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=Negev%20|%20Nuclear%20Waste%20(Minimal%20Wear)

请注意,大约1小时前,这有效但现在抛出错误,有什么建议吗?

2 个答案:

答案 0 :(得分:1)

您的回复状态为429 Too many requests

  

用户在给定的时间内发送了太多请求(“费率   限幅“)。

所以这个网站可以阻止过于频繁地引用他的API

答案 1 :(得分:1)

HTTP 429是一个太多的请求警告,它不是一个错误,只是一个说明,告诉你你做了一点。您必须等待一段时间,或者如果它是您自己的服务器,则调整它的设置以允许更多请求。

相关问题