将 Steam 应用列表加载为 JSON 文件

Load steam applist as JSON file

我一直在尝试从此 url“https://api.steampowered.com/ISteamApps/GetAppList/v2/?key=XXXXXXXXXetc”加载 Steam 应用列表。我已经尝试了我认为的所有组合,使用 AJAX,使用 PHP 下载它,但我还没有找到可行的方法,希望你能帮忙!

提前致谢,Magn0053

试试这个:

<?php

$jsonString = file_get_content("https://api.steampowered.com/ISteamApps/GetAppList/v2/?key=XXXXXXXXXetc");

$listArray = json_decode($jsonString, true);
echo "<ul id="listResults">\r\n";
foreach($listArray as $k => $v){
    echo "<li><label>$k</label>: $v</li>\r\n";
}
echo "</ul>\r\n";
?>

这也可以在 JQuery 中完成(示例:http://jsfiddle.net/Twisty/be5h65L3/):

$(function(){
    $("#getListBtn").click(function(){
        var url = 'https://api.steampowered.com/ISteamApps/GetAppList/v2/?key=XXXXXXXXXetc&callback=?';

        $.ajax({
            type: 'GET',
            url: url,
            async: false,
            jsonpCallback: 'jsonCallback',
            contentType: "application/json",
            dataType: 'jsonp',
            success: function(data) {
               $.each(data, function(k, v){
                   $("#listResults").append("<li><label>" + k + "<label>: " + v + "</li>");
               });
            },
            error: function(e) {
               console.log(e.message);
            }
        });
    });
});