Laravel 5.8卷曲中的后期调用效果很好,但不适用于

时间:2019-08-28 08:41:24

标签: laravel http guzzle

当我在终端中卷曲地执行此帖子时,一切正常,我看到该帖子进入了

我的通话:

curl -X POST https://requestloggerbin.herokuapp.com/bin/a4d73cbb-2ddc-4fc7-ac38-60c2fac7e015 -d '{"test": "foo"}'

我正在尝试用枪口在我的laravel应用中复制此调用,但是我看不到后调用,并且我也没有收到任何错误消息,所以我不知道出了什么问题。

我的狂饮电话:

$client = new Client();

$request = $client->post(
    'https://requestloggerbin.herokuapp.com/bin/a4d73cbb-2ddc-4fc7-ac38-60c2fac7e015',
    ['body' => ['foo' => 'bar']]
);
$response = $request->send();

我在这里做什么错了?

1 个答案:

答案 0 :(得分:1)

$response = $request->send();

根本不需要。

use GuzzleHttp\Client;

$client = new Client();
$response = $client->post('http://localhost.com/23', ['body' => $requestXmlBody]);

$result = $response->getBody()->getContents();

$result1 = simplexml_load_string($result);