【问题标题】:file_get_contents failing when was working earlierfile_get_contents 在早期工作时失败
【发布时间】:2016-03-11 00:49:17
【问题描述】:

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

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

但第 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 请求失败! HTTP/1.0 429 Unknown in /home4/matt500b/public_html/themooliecommunity.com/CSGO/index.php 第 24 行

我可以确认 allow_url_fopen 已开启

将以下网址粘贴到浏览器中表明该网址有效

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

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

【问题讨论】:

  • 429 Too Many Requests (RFC 6585) 用户在给定时间内发送的请求过多。旨在与速率限制方案一起使用。[57]

标签: php api http-headers


【解决方案1】:

您的回复状态为429 Too many requests

用户在给定时间内发送的请求过多(“rate 限制”)。

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-30
      • 2015-05-18
      • 1970-01-01
      • 2017-03-22
      • 1970-01-01
      • 2016-03-04
      相关资源
      最近更新 更多