如何解决错误-“提交的URI太大!”

时间:2019-05-26 12:09:50

标签: laravel curl

我正在使用curl方法在laravel中获取响应。然后,我解码响应数据并从控制器发送到视图页面,但出现错误-

  

提交的URI太大!

我的代码在detailController.php-

public function details(Request $request)
    {

$json_data = array('requested data on array');          
$data_json = json_encode($json_data);           
$curl = curl_init();
curl_setopt_array($curl, array(
            CURLOPT_URL => "url where we send the request",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 20,
            CURLOPT_TIMEOUT => 50,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST",
            CURLOPT_POSTFIELDS => $data_json,
            CURLOPT_HTTPHEADER => array(
                    "accept: application/json",
                    "api-key: key provided from url",
                    "cache-control: no-cache",
                    "content-type: application/json"
                  ),
                ));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "error";           } 
else {
$getdetails = json_decode($response, true);
return view('viewpageurl', compact('getdetails'));
}           
}

viewpageurl.blade.php

@if($getdetails)            
 @foreach($getdetails as $getname)
  <h2>{!! $getname->details->name !!}</h2>
 @endforeach
@endif

0 个答案:

没有答案