我找到了从API到我的网站获取ID的解决方案。
但是,我仍然不知道如何替换它:(来自http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=APIKEY&steamid=76561198108107219&format=json)
"id": 1960542190,
"defindex": 744,
这样:(来自http://api.steampowered.com/IEconItems_440/GetSchema/v0001/?key=APIKEY)
"name": "Pyrovision Goggles",
"defindex": 744,
我正在使用它:
$url = "http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=" . $api_key . "&steamid=" . $idc . "&format=json";
$json_object= file_get_contents($url);
$json_decoded = json_decode($json_object);
foreach ($json_decoded->result->items as $item)
{
$items[$item->id]['id'] = $item->id;
$items[$item->id]['original_id'] = $item->original_id;
$items[$item->id]['defindex'] = $item->defindex;
$items[$item->id]['level'] = $item->level;
$items[$item->id]['quality'] = $item->quality;
echo $item->defindex; echo "<br>";
}
答案 0 :(得分:0)
您拥有玩家的广告资源,现在您需要提取项目架构。
$url = "http://api.steampowered.com/IEconItems_440/GetSchema/v0001/?key=" $APIKEY;
$json_object= file_get_contents($url);
$schema_json_decoded = json_decode($json_object);
$items_schema = $schema_json_decoded->result->items;
架构项现在位于$items
变量中。在foreach
循环中,我们需要将播放器项目的defindex
与架构中的defindex
es进行比较:
foreach ($json_decoded->result->items as $item)
{
...
$items[$item->id]['defindex'] = $item->defindex;
...
foreach ($items_schema as $item)
{
if ($items[$item->id]['defindex'] == $item->defindex)
{
$items[$item->id]['name'] = $item->item_name;
}
}
}
您的商品名称现已存储在$items[$item->id]['name']
中。