无法通过GuzzleHttp

时间:2019-07-15 15:56:11

标签: php guzzlehttp

我正在尝试使用GuzzleHttp从一个应用程序发布到另一个应用程序,如下所示:

public function connect() {
    $request = $this->client;
    $options = [
        'json' => [
            "email" => self::authEmail,
            "password"=> self::authKey
        ]
    ];
    $response = $request->request('POST',self::apiURL,$options);
    return json_decode($response->getBody()->getContents(), true)['token'];
}

public function sendMail($body) {
    $request = $this->client;
    $headers = [
        'Authorization' => 'Bearer '. $this->connect(),
        'Content-Type' => 'application/json'
    ];


    $response = $request->request('POST','http://localhost:8000/api/email/process-booking',[
        'headers' => $headers,
        'json' => [
            'name' => 'Example name',
        ],

        'debug'=> true,

    ]);

    return $response->getBody()->getContents();
}
  

致命错误:未捕获的GuzzleHttp \ Exception \ ServerException:服务器错误:POST http://localhost:8000/api/email/process-booking导致500 Internal Server Error响应:

启用调试后,出现此错误:

  

警告:curl_setopt_array():无法在第56行的C:\ xampp \ htdocs \ comunReservacion \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php中将输出类型的流表示为STDIO FILE * >      

警告:curl_setopt_array():无法在第56行的C:\ xampp \ htdocs \ comunReservacion \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php中将输出类型的流表示为STDIO FILE * >      

警告:curl_setopt_array():无法在第56行的C:\ xampp \ htdocs \ comunReservacion \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php中将输出类型的流表示为STDIO FILE * >      

致命错误:未捕获的GuzzleHttp \ Exception \ RequestException:cURL错误0:cURL请求已重试3次,但未成功。失败的最可能原因是cURL无法回退请求的正文,并且随后的重试导致了相同的错误。打开调试选项,看看出了什么问题。有关更多信息,请参见https://bugs.php.net/bug.php?id=47204。 (请参见http://curl.haxx.se/libcurl/c/libcurl-errors.html),位于C:\ xampp \ htdocs \ comunReservacion \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php:186堆栈跟踪:#0 C:\ xampp \ htdocs \ comunReservacion \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php(517):GuzzleHttp \ Handler \ CurlFactory :: createRejection(Object(GuzzleHttp \ Handler \ EasyHandle),Array)#1 C:\ xampp \ htdocs \ comunReservacion \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php(146):GuzzleHttp \ Handler \ CurlFactory :: retryFailedRewind(Object(GuzzleHttp \ Handler \ CurlHandler),Object(GuzzleHttp \ Handler \ EasyHandle),Array)#2 C:\ xampp \ htdocs \ 186行上的comunReservacion \ vendor \ guzzlehttp \ guzzle \在C:\ xampp \ htdocs \ comunReservacion \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php中

奇怪的是,连接成功,仅当我尝试发布数据时才会出现问题

0 个答案:

没有答案