【发布时间】:2015-08-01 02:30:54
【问题描述】:
我正在从一个站点获取 json 文件,我希望它找到哪个获取该文件并使用该文件。我也在使用 $_GET 方法。有两种方法可以获取相同的文件,但它们都需要一个 id 或来自 steam 的自定义 url。
我的网址示例:www.mysite.com?id=123123123
2种获取json文件的方式:
- http://steamcommunity.com/id/ID/inventory/json/730/2
- http://steamcommunity.com/CUSTOMURL/76561198051643107/inventory/json/730/2
我是如何解码的:
$id = $_GET['id'];
$url = "http://steamcommunity.com/id/".$id."/inventory/json/730/2";
$content = file_get_contents($url);
$playerinfo = json_decode($content, true);
$InventoryStatus = $playerinfo['success'];
【问题讨论】:
-
有什么问题?代码不工作?
-
@borracciaBlu 我找不到它,所以它会尝试其中一个 url,看看它是否给你一个 json,如果没有,它会尝试另一个,如果没有,它会返回其他东西
-
您在 JSON 中寻找的特定元素是否可以作为回报的依据?
-
使用 if() 语句。
-
@BuzzotheSplitter 每个人都不同...
标签: php json parsing steam-web-api