我通过 curl 在基于 ssl 方法 (https) 的 api 上设置订单数据,但它返回 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 消息。
这是我根据客户要求的 json 的测试代码:
$apiKey = "xxxxxx-xxxxxx-xxxxx-xxxxxx-xxxxxx";
$privatekey = "xxxxxx-xxxxxx-xxxxx-xxxxxx-xxxxxx";
$timestamp = date('Y-m-d H:i:s'); // (for example: 2016-07-19 14:05:55)
$signature = hash_hmac('sha1', $timestamp, $apiKey);
$signature = hash_hmac('sha1', $privatekey, $signature);
$postURL = "https://www.compu-cover.com/intelligent-rewards/orders/?OrderNo=123";
$orderInfo['Order'] = array(
"apiKey" => $apiKey,
"privatekey" => $privatekey,
"Signature" => $signature,
"Timestamp" => $timestamp,
"Firstname" => "Ajay",
"Surname" => "Sharma",
"EmailAddress" => "ajay@yopmail.com",
"DaytimeTel" => "0141798526",
"EveningTel" => "0141798526",
"MobileTel" => "9887654321",
"Address1" => "A-5",
"Address2" => "Jhalana",
"Address3" => "Jaipur",
"Address4" => "Rajasthan",
"County" => "India",
"Postcode" => "302019",
"Cover" => "ADTBL",
"Scheme" => 2,
"Premium" => 5,
"EquipmentQty" => 1,
"EquipmentType1" => "Smartphone",
"EquipmentMake1" => "Moto",
"EquipmentModel1" => "Moto G",
"EquipmentPrice1" => 100
);
$params = json_encode($orderInfo);
$session = curl_init($postURL);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($session);
if (FALSE === $response) {
var_dump(curl_error($session));
var_dump(curl_errno($session));
}
curl_close($session);
$response = json_decode($response);
var_dump($response);
如何查找失败原因?失败的原因可能是什么?请提供您的建议。
原文由 SohanLal Saini 发布,翻译遵循 CC BY-SA 4.0 许可协议
在标准 C 库中,变量
errno
包含最近系统调用出错的代码。 104 的值定义为ECONNRESET
表示“连接由对等方重置”。该错误只是意味着对方挂断了您,没有完成正常的 HTTPS 协议并返回任何回报……可能出于各种原因,可能是网络问题,也可能是服务器端程序崩溃,或者另一端只是不喜欢你所做的。它与 OpenSSL 根本没有关系,要知道是什么原因造成的,您需要访问服务器日志。