我只想问一个问题,我怎么能定义“0”? 代码:https://paste.laravel.io/gQYKN#19
<?php
$apiKey = 'api';
$steamId = 1337;
$apiUrl = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $apiKey . '&steamids=' . $steamId;
$json = json_decode(file_get_contents($apiUrl), true);
$join_date = date("D, M j, Y", $json["response"]["players"][0]["timecreated"]);
function personalState ($state) {
$states = [
1 => 'Online',
2 => 'Busy',
3 => 'Away',
4 => 'Snooze',
5 => 'Looking for trade',
6 => 'Looking to play'
];
if (!empty($states[$state])) {
return $states[$state];
}
return 'Offline';
}
答案 0 :(得分:0)
我对Steam API有丰富的经验;您有一个无效的API密钥,或者您提供的SteamID不正确。除非你展示print_r($json);
的输出,否则没有明确的方法来判断哪个。
确保SteamID具有以下格式:7656xxxxxxxxxxxxx(其中x&#39; s全部为数字,SteamID64&#39; s全部为17位数字),并且您在此处找到了正确的API密钥:{{3 }}