【发布时间】:2019-07-28 08:57:18
【问题描述】:
我也在谷歌上搜索过 StackOverflow(只找到这个:Steam API all games)
我想要实现的是列出 Steam 商店中满足以下条件的所有可用游戏: - 包括标签:TPP - 将是一种类型:游戏(不是插件/配乐等)
如何进行呢?我没有线索。在 github 上搜索,但只有一些类可以检索特定的用户数据库。
当前代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<?php
$url = 'http://api.steampowered.com/ISteamApps/GetAppList/v0002/?key=XXXXXX?tags=1697&os=win&category1=998%2C996&format=json'; // path to your JSON file
$data = file_get_contents($url); // put the contents of the file into a variable
$characters = json_decode($data); // decode the JSON feed
echo $characters[0]->name;
var_dump($data);
var_dump($characters);
?>
<table>
<tbody>
<tr>
<th>Name</th>
</tr>
<?php foreach ($characters as $character) : ?>
<tr>
<td> <?php echo $character->name; ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
【问题讨论】:
-
请编辑您的问题以包含
var_dump($data);和var_dump($characters);的输出,以便进行调试以查看您得到的结果。当您打开 API URL 时,您会注意到 JSON 中有一个applist条目,您没有在代码中读取。 -
经过更改测试。 var_Dump 什么也没显示。从字面上看,页面是空白的。老实说,不知道如何解决 applist 的问题。
-
当你没有得到任何输出时(
var_dump()总是产生一些输出),你必须检查stackoverflow.com/questions/1475297/phps-white-screen-of-death 看不到的错误消息。
标签: steam-web-api