我想用php做一个接口,可以向客户端发送json数据,像这样的:
$content = file_get_contents("http://api.letvcloud.com/gpc.php?cf=html5&sign=signxxxxx&ver=2.1&format=json&uu=9a41a0d696&vu=f00b908640");
$data = json_decode($content,true);
echo $data["code"];
人家的页面打开后是这样的:
{"code":10090,"data":[],"message":"\u6821\u9A8C\u7801\u9519\u8BEF","total":0}
我可以取到数据,我自己写的接口的代码:
<?php
$arr = array();
$arr["name"] = "name";
$arr["age"] = 24;
$json = json_encode($arr);
echo($json);
?>
然后我用同样的方法取不到数据,请问我是哪里错了?求大神啊!!!!!!!!
$content = file_get_contents("http://api.letvcloud.com/gpc.php?cf=html5&sign=signxxxxx&ver=2.1&format=json&uu=9a41a0d696&vu=f00b908640");
$data = json_decode($content,true);
echo $data["code"];
人家的页面打开后是这样的:
{"code":10090,"data":[],"message":"\u6821\u9A8C\u7801\u9519\u8BEF","total":0}
我可以取到数据,我自己写的接口的代码:
<?php
$arr = array();
$arr["name"] = "name";
$arr["age"] = 24;
$json = json_encode($arr);
echo($json);
?>
然后我用同样的方法取不到数据,请问我是哪里错了?求大神啊!!!!!!!!