我目前正在使用(Guzzle client/Laravel)对自定义API进行rest API调用。我通过添加错误的 body 尝试了几次。我收到以下错误
cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
以下是我的开发环境的详细信息:
Language : php,
Framework : Laravel 5.4,
Client : Guzzle,
OS : Ubuntu 16.04
我想知道这背后的原因
请在这件事上帮助我,
谢谢
以下是我的代码
{
$headers = [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer '.$this->accessTocken,
'Accept' => 'application/json',
];
$Body = [
'method' => 'AndroidApp',
'msisdn' => '94777400725',
];
$client = new Client();
$response = $client->post( $this->url, ['headers'=> $headers,
'json'=> $Body]);
}
最佳答案
$ response-> getBody()-> rewind();
为我工作
关于php - cURL请求已重试3次,但未成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58112931/