gpt4 book ai didi

php - 错误 (56) : Failure when receiving data from the peer for rest API post method request using PHP

转载 作者:行者123 更新时间:2023-12-05 07:46:11 25 4
gpt4 key购买 nike

响应应该是 XML,但我收到类似 (56): Failure when receiving data from the peer 的错误,同时使用 header 将请求发送到 REST API,这是示例请求给客户

POST http://api.toyotautrust.in/1.0/olx/inventory HTTP/1.1
User-Agent: Fiddler
Authorization: Token ******-****-****-****-***********
Host: api.toyotautrust.in
Content-Length: 52

这是我使用 cURL 用 PHP 编写的请求代码

$headers1=[
'POST /1.0/olx/inventory HTTP/1.1',
'Host: api.toyotautrust.in',
'User-Agent: Fiddler',
'Authorization: Token' .$atoken1,
'Content-Length: 52'];
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, 'http://api.toyotautrust.in/1.0/olx/inventory');
curl_setopt($ch1, CURLOPT_POST, true);
curl_setopt($ch1, CURLOPT_HEADER, true);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_HTTPHEADER,$headers1);
$response1 = curl_exec($ch1);
print_r($response1);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $status_code1;

最佳答案

我在 POST 请求中发送这两个 header 失败了

'User-Agent:Fiddler',
"Content-length: 0",

添加这两个 header 后,一切正常。在将您的请求发送到服务器之前,请向服务器端人员询问 header 和参数

关于php - 错误 (56) : Failure when receiving data from the peer for rest API post method request using PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41118232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com