繁体   English   中英

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

[英]response bad request in http request with php

当我尝试发送 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()参考链接https://laravel.com/docs/8.x/http-client#headers

$response = Http::withHeaders(["Content-Type"=>"application/x-www-form-urlencoded"])
    ->withToken($access_token)
    ->timeout('2000')
    ->get('https://example /.../...',[
    ]);`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM