Laravel 5.8 在卷曲中调用后效果很好,但不适合 guzzle



当我使用 curl 在我的终端中执行此帖子调用时,一切正常时,我看到发布呼叫进来:

我的卷发电话:

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

我正在尝试使用 guzzle 在我的 laravel 应用程序中复制此呼叫,但我没有看到帖子呼叫进来,也没有收到任何错误消息,所以我不知道出了什么问题。

我的呼唤:

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

我在这里做错了什么?

$response = $request->send();

这根本不需要.

use GuzzleHttpClient;
$client = new Client();
$response = $client->post('http://localhost.com/23', ['body' => $requestXmlBody]);
$result = $response->getBody()->getContents();
$result1 = simplexml_load_string($result);

相关内容

最新更新