如何搜索 Steam 游戏 API JSON 输出?

How to search Steam game API JSON output?

我正在与以下 API 合作:

http://api.steampowered.com/ISteamApps/GetAppList/v0002/?format=json

https://store.steampowered.com/api/appdetails?appids=GAMEID (gameid 示例:“730”- 反恐精英)

我对这两者的目标是在其中搜索数据。例如,我希望第一个 API 根据它的 ID 给我一个游戏名称,第二个给我关于游戏的特定信息,例如它是否有交易卡(id:29 在 API).

我尝试了一些东西,但我有点迷茫,因为我不太明白 JSON 所以我真的很感激你的帮助。
我对 PHP 和 JS 解决方案持开放态度。

IN PHP,可以使用json_decode()函数将JSON数据转换成数组。您可以像访问经典数组一样访问这些值:

$appID = 730 ;
$url = 'https://store.steampowered.com/api/appdetails?appids=' . $appID ;

$content = file_get_contents($url) ; // retrieve the JSON data string from the website
$data = json_decode($content, true); // convert the JSON string into PHP array 

echo $data[$appID]['data']['name'] ; // Counter-Strike: Global Offensive
var_dump($data[$appID]['data']['is_free']); // bool(true)