Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.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 将数据表单视图传递给控制器guzzle Laravel 5_Php_Laravel_Api_Guzzle6 - Fatal编程技术网

Php 将数据表单视图传递给控制器guzzle Laravel 5

Php 将数据表单视图传递给控制器guzzle Laravel 5,php,laravel,api,guzzle6,Php,Laravel,Api,Guzzle6,我试着在用火发送数据时使用guzzle,结果总是出现错误 500内部服务器错误 以下是我正在执行的代码: 查看 <form action="{{URL(route('coba.index'))}}" method="POST"> <div class="row"> <div class="col m6"> <div class="row"> <div class=

我试着在用火发送数据时使用guzzle,结果总是出现错误

500内部服务器错误

以下是我正在执行的代码:

查看

<form action="{{URL(route('coba.index'))}}" method="POST">
    <div class="row">
        <div class="col m6">
            <div class="row">
                <div class="input-field col s12">
                    {{ csrf_field() }}
                    <label for="promoname">Promo Name</label>
                    <input id="promoname" name="promoName" type="text">
                </div>
                <div class="input-field col s12">
                    <label for="promocode">Promo Code</label>
                    <input id="promocode" name="promoCode" type="text">
                </div>
</form>

有人知道我的错误吗???

在您的表单中传递令牌:
{!!csrf_field()!!}

检查一下。谢谢

信息不够,对于状态代码500,您必须检查服务器日志才能了解真正的问题。PHP-FPM日志、Laravel日志等。哦,谢谢你,它帮助了我
<?php
    namespace App\Http\Controllers;
    use GuzzleHttp\Client;
    class GuzzleController extends Controller
    {
        public function getRemoteData(){            
            $client = new Client;            
            $data = Input::all();
            $promo_name=$data['promoName'];
            $promo_code=$data['promoCode'];

            $url = "http://192.168.0.41:88/API_CmsDeveloop/public/api/v1/price-rules/store";
            $request = $client->post($url, [
                'form_params' => [
                    "promo_name" => $promo_name,
                    "promo_code" => $promo_code
                    ]
            ]);            
            echo '<pre>';
            print_r($request );
        }
    }
Route::post('/cobaGuzzle','GuzzleController@getRemoteData')->name('coba.index');