为了账号安全,请及时绑定邮箱和手机立即绑定

guzzle 6 500 内部服务器错误 BadMethodCallException

guzzle 6 500 内部服务器错误 BadMethodCallException

PHP
有只小跳蛙 2022-12-23 16:31:47
我正在尝试大口大口地提出要求。我有两个条件,当数据有令牌时,如果否则继续。其他部分在发送时工作,但如何传递标头,它显示内部服务器错误$数据是这样的:Array ( [userId] => 87 [token] => eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImI2ZGE3ZTM4ODYyYWU5NzQwNWNlZDcxYTQ3YzIzNTY4ZGU1MzU4ODA4YmI4YjUzZDJlNGI1YTE1ZGQ0NjMyZWRjYzc0ZTllNmZiZGQ1MGI0In0.eyJhdWQiOiIxIiwianRpIjoiYjZkYTdlMzg4NjJhZTk3NDA1Y2VkNzFhNDdjMjM1NjhkZTUzNTg4MDhiYjhiNTNkMmU0YjVhMTVkZDQ2MzJlZGNjNzRlOWU2ZmJkZDUwYjQiLCJpYXQiOjE1ODcxMDI3NDIsIm5iZiI6MTU4NzEwMjc0MiwiZXhwIjoxNjE4NjM4NzQyLCJzdWIiOiI4NyIsInNjb3BlcyI6W119.WwtepUSktopeikIL-7n3BfZYLO0_rhLSfT13yt1jo8xJp5xZBh2_WVexy8ifXx2oTgVX3n2JB-I3aAMYVbeJP-6SHsyF81LqvOQDYm-Jx9YBI4ihksbF1tDx8mjtmFUTnLAJBn1V451oUVtomAFaQ4xIQxn7AFaxVPF_MY_dziPf4dWSSehq9pP6IAn7yXGlRiBdnpmsca_m03FcLlGwpLc3tGh7qIEjg726kFecvzy7xDyUtJ1CPy0N-bErMDg_Cdvaidbqg5oJoBL8Zuw8Ec1k9DrKAxtGqAuo2OwMjoQlXcavuga_-Mwrh4MKdoH6WyXSOlHze4H_o0w2g7JtRVG4lrUz6NuA0Ys1DlAIZd5V1E44eNFfu849Magtfaun4AbOAQpHKNtF3G9efkcT0OVHsl3qct3OvjNzFWOALDV8Cops_rsVWz1goWbkz0gvJas8eGq0V7qPIdo-ZdHt7RX-GJWILvC9B9uUgWr3GGNQqIAPMzIV4i6VMd0v_VggJk9pDCGMyhLP2fw6SOGFYi33U0IkNApEPCeqixpAAybZlJbt8EnfS1XXKyjDRZH2W-PfJyO_cSoO4gaXLJktoL0ew5uVRvda-UcQnl2dPTPNQbcPG3S0_ADyyMJdsgJDlDebTikuRSOwENpwFBmDJAYTMT9Zu3Y8hDwARsK5vJI [language] => en )     if (isset($data['token'])){    $headers = [        'Authorization' => 'Bearer '.$data['token'],        'Content-Type' => 'application/json'    ];    $response = $client->request($requestType,$url,    [       'json' => [           'header' => $headers,           'data' => $data       ]]);}else{   $headers = [       'content-type' => 'application/json'   ];    $response = $client->request($requestType,$url,    [        'json'   => $data]);}$contents = json_decode($response->getBody()->getContents(), true);           return $contents;
查看完整描述

1 回答

?
鸿蒙传说

TA贡献1865条经验 获得超7个赞

尝试一下


$response = $client->request($requestType,$url,

    [

       'json' => $data,

       'headers' => $headers,

]);


查看完整回答
反对 回复 2022-12-23
  • 1 回答
  • 0 关注
  • 93 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信