我需要发送一个请求到外部web服务,我的web服务返回json。这两个项目都是本地的。第一个是localhost/symfony…第二个localhost/login/index.php
$uri = "http://localhost/login/index.php";
$request = Request::create($uri, 'GET', array('test' => 'test'));
我不知道如何发送请求和检索响应。
请求对象为内部使用。您最好使用HTTP客户端,如
- Buzz
- 狂饮
- 原始卷
您可以使用file_get_contents()从web服务获取json格式的数据,然后您可以使用json_decode()对其进行解析。