请问下Laravel与andriod的app通信

WBOY
Release: 2016-06-20 12:46:42
Original
816 people have browsed it

请问下Laravel与andriod的app通信是可直接用$_POST、$_GET接收,然后echo json_decode(xxx);返回信息吗  这个放的位置可以任意放置吗


回复讨论(解决方案)

就写个接口嘛,找个文件夹放着就可以了

接收参数就是使用$_GET,$_POST来获取
返回数据是用 echo json_encode(xxxx); 而不是 echo json_decode(xxxx);

 返回时需要加上header,
header('content-type:application/json');

接收参数就是使用$_GET,$_POST来获取
返回数据是用 echo json_encode(xxxx); 而不是 echo json_decode(xxxx);

 返回时需要加上header,
header('content-type:application/json');


嗯  写错了 还回的应该是JSON数据格式,但是Laravel中应该如何做了 ?我知道怎么接收 但不知道应该放置在哪里比较好 是route还是视图blade 还是控制器 
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!