【发布时间】:2017-09-09 08:53:31
【问题描述】:
我想获取一个包含 dota 2 价格的所有项目的列表。 使用此代码:
<?$urll2 = "http://api.steamapis.com/market/items/570?api_key=******";
enter code here$urljson2 = file_get_contents("$urll2");
$data2 = json_decode($urljson2);
echo $data2;
?>
并显示此错误:
警告: file_get_contents(http://api.steamapis.com/market/items/570?api_key=4E465E3EC414FE37DAE8357EF7F01863) [function.file-get-contents]:无法打开流:HTTP 请求 失败的! HTTP/1.1 401 未经授权
【问题讨论】:
-
HTTP/1.1 401 Unauthorized 正如它所说,您无权获取内容。检查您的 API 密钥。
-
如果我使用 localhost 的 API 密钥,在 Steam 中我是否必须将它带到 localhost?
-
如果你直接访问这个 URL,它会给我 JSON 响应:
{"error":"Missing required 'api_key' parameter."}。在570后面加上问号?。 -
我有吗?但它不起作用
-
您使用的是 Steam API 密钥吗?您从steamcommunity.com/dev/apikey 获得的那个还是使用来自steamapis.com 的那个?
标签: php json steam steam-web-api