Steam API 调用无法打开流

Steam API call failed to open stream

您好,我只是为了好玩而开发私人网页。我打电话从 steam API 获取一个 json,这样我就可以获得用户的头像。这是我的代码。

function getSteamImage() {
    $key = "XXXXXXXXXXXXXXXXXXXXXXXXXXX";
    $json = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$key&steamids=76561197960435530');
    $json_array = json_decode($json,true);
    $image = $json_array["response"]["players"]["avatar"];
    return $image;
}

<li><img src="<?= getSteamImage() ?>"></li>

但是我现在收到这个错误:

file_get_contents(http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXXXXXXXXXXXXXXX&steamids=76561197960435530): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

顺便说一句,我在这里使用的 Steam 密钥不是我在脚本中使用的密钥!

找到了问题,但这不是我的错。

//Instead of this
$json_array["response"]["players"]["avatar"];

//It has to be this
$json_array["response"]["players"][0]["avatar"];

在播放器中有一个索引为 0 的 array