有什么方法可以加快此功能?这会花费太多时间,有时会无法正常工作
<?php
$json = file_get_contents('http://xxxxxxxx/players.json');
$data = json_decode($json,true);
for ($i=0; $i< count($data); $i++)
{
$temp = explode(":",$data[$i]['identifiers'][0]);
$json2 = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXXXXXXXXXXXX&steamids=' . hexdec($temp[1]) . '');
$data2 = json_decode($json2);
$playerData = ''. $data2->response->players[0]->personaname . ',' . $data2->response->players[0]->avatarfull .'';
echo($playerData);
echo "<br>";
}
?>
是,您一次可以获取多个ID。根据文档,您可以在用户ID之间使用逗号,并且一次最多可以获取100个。
[Comma-delimited list of 64 bit Steam IDs to return profile information for. Up to 100 Steam IDs can be requested.
https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29
在第一个$ json之后,循环遍历并将标识符添加到数组中。然后使用$ json2创建一个调用,在其中将$ json中的ID插入,每个ID之间用逗号分隔。
如果您期望超过100个ID,那么您将不得不拨打更多电话。