我想检索我的本地主机上的JSON对象,问题是它不会输出任何东西。 JSON对象可能如下所示:不能检索本地主机上的JSON对象
[
{
NAME: "Hearthstone",
PLAYER1: "Rdu ",
PLAYER2: "Savjz ",
status: 2,
meta: "LIVE"
},
{
NAME: "League of Legends",
PLAYER1: "Team King ",
PLAYER2: "EDG ",
status: 2,
meta: "28.12."
}]
php检索对象。
$url = "http://localhost:8888/crawl_JSON.php";
$json = file_get_contents($url);
$json_output = json_decode($json);
echo $json_output;
为什么不输出任何东西?
你确定该链接返回一个json对象吗? – gbestard 2014-12-27 18:05:25
而不是使用PHP下载,使用浏览器。这是否足够有效,即返回200状态码和预期的JSON数据?如果没有,那么你看错了地方。 – 2014-12-27 18:09:03