Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从Laravel检索Guzzle(6.3)发送的POST数据_Php_Laravel_Guzzle - Fatal编程技术网

Php 从Laravel检索Guzzle(6.3)发送的POST数据

Php 从Laravel检索Guzzle(6.3)发送的POST数据,php,laravel,guzzle,Php,Laravel,Guzzle,我正在将我的laravel应用程序中的一些数据发布到本地服务器上的另一个普通PHP页面上。Guzzle返回的状态码说它成功了,但我无法访问它。我该怎么做 我尝试使用Post方法来检索值,但没有成功 Guzzle功能: $client=newclient(); $response=$client->request('POST','http://localhost/testApp/guzTest.php', [ “表单参数”=>[ “amnt”=>75 ], “允许重定向”=>true ]); ec

我正在将我的laravel应用程序中的一些数据发布到本地服务器上的另一个普通PHP页面上。Guzzle返回的状态码说它成功了,但我无法访问它。我该怎么做

我尝试使用Post方法来检索值,但没有成功

Guzzle功能:

$client=newclient();
$response=$client->request('POST','http://localhost/testApp/guzTest.php',
[
“表单参数”=>[
“amnt”=>75
],
“允许重定向”=>true
]);
echo$response->getStatusCode();
接收POST数据的页面:

<?php
    if (!empty($_POST['amnt'])) {
        echo $_POST['amnt'];
    }else
        echo 'not found';   
?>


我希望能够通过post方法访问发布的金额,但没有任何结果。

尝试类似的操作

 $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);

试试这样的事

 $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);

请确认您正在使用的guzzle版本。请确认您正在使用的guzzle版本。