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响应http请求中的错误请求_Php_Laravel_Rest - Fatal编程技术网

使用php响应http请求中的错误请求

使用php响应http请求中的错误请求,php,laravel,rest,Php,Laravel,Rest,当我尝试发送http请求时,它会返回状态400(请求错误,标头无效) API需要访问令牌和内容类型:application/x-www-form-urlencoded 这是我的代码: 访问令牌非常长 请帮帮我 $response = Http::contentType('application/x-www-form-urlencoded') ->withToken($access_token) ->timeout('2000')

当我尝试发送http请求时,它会返回状态400(请求错误,标头无效) API需要访问令牌和内容类型:application/x-www-form-urlencoded 这是我的代码: 访问令牌非常长 请帮帮我

$response = Http::contentType('application/x-www-form-urlencoded')
            ->withToken($access_token)
            ->timeout('2000')
            ->get('https://example /.../...',[
            ]);`
使用
withHeaders()
ref链接

$response=Http::withHeaders([“内容类型”=>“应用程序/x-www-form-urlencoded”])
->withToken($access\u token)
->超时('2000')
->得到('https://example /.../...',[
]);`