从 Laravel 检索使用 Guzzle (6.3) 发送的 POST 数据
Retrieve POST data sent with Guzzle (6.3) from Laravel
我正在 post 将一些数据从我的 laravel 应用程序传输到我本地服务器上的另一个普通 PHP 页面。 Guzzle 返回的状态代码表示它已成功,但我无法访问它。我该怎么做?
我试过使用 Post 方法检索值,但没有成功
Guzzle 函数:
$client = new Client();
$response = $client->request('POST', 'http://localhost/testApp/guzTest.php',
[
'form_params' => [
'amnt' => 75
],
'allow_redirects' => true
]);
echo $response->getStatusCode();
正在接收页面 POST 数据:
<?php
if (!empty($_POST['amnt'])) {
echo $_POST['amnt'];
}else
echo 'not found';
?>
我希望能够通过 post 方法访问 posted 的数量,但没有任何结果。
尝试类似的东西。
$client = new Client();
$response = $client->request('POST', 'http://localhost/testApp/guzTest.php',
[
'form_params' => [
'amnt' => 75
],
'allow_redirects' => true
]);
$contents = $response->getBody()->getContents();
$contents = json_decode($contents,true);
return ($contents);
在接收 POST 数据的页面上:
响应应该是这样的
return response()->json([
'status' => 'SUCCESS',
'code' => '200',
], 200);
我正在 post 将一些数据从我的 laravel 应用程序传输到我本地服务器上的另一个普通 PHP 页面。 Guzzle 返回的状态代码表示它已成功,但我无法访问它。我该怎么做?
我试过使用 Post 方法检索值,但没有成功
Guzzle 函数:
$client = new Client();
$response = $client->request('POST', 'http://localhost/testApp/guzTest.php',
[
'form_params' => [
'amnt' => 75
],
'allow_redirects' => true
]);
echo $response->getStatusCode();
正在接收页面 POST 数据:
<?php
if (!empty($_POST['amnt'])) {
echo $_POST['amnt'];
}else
echo 'not found';
?>
我希望能够通过 post 方法访问 posted 的数量,但没有任何结果。
尝试类似的东西。
$client = new Client();
$response = $client->request('POST', 'http://localhost/testApp/guzTest.php',
[
'form_params' => [
'amnt' => 75
],
'allow_redirects' => true
]);
$contents = $response->getBody()->getContents();
$contents = json_decode($contents,true);
return ($contents);
在接收 POST 数据的页面上: 响应应该是这样的
return response()->json([
'status' => 'SUCCESS',
'code' => '200',
], 200);