这是封装的方法:
private function _connectByCURL($url, $body, $http_header = false, $identify = false) {
$ch = @curl_init();
if (!$ch) {
$this->_logs[] = $this->paypal->l('Connect failed with CURL method');
} else {
$this->_logs[] = $this->paypal->l('Connect with CURL method successful');
$this->_logs[] = '<b>'.$this->paypal->l('Sending this params:').'</b>';
$this->_logs[] = $body;
for ($attempt = 0; $attempt < 3; $attempt++) {
@curl_setopt($ch, CURLOPT_URL, 'https://' . $url);
if ($identify) {
@curl_setopt($ch, CURLOPT_USERPWD, Configuration::get('PAYPAL_LOGIN_CLIENT_ID') . ':' . Configuration::get('PAYPAL_LOGIN_SECRET'));
}
@curl_setopt($ch, CURLOPT_POST, true);
if ($body) {
@curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_HEADER, false);
@curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
//@curl_setopt($ch, CURLOPT_SSLVERSION, Configuration::get('PAYPAL_VERSION_TLS_CHECKED') == '1.2' ? 6 : 1);
@curl_setopt($ch, CURLOPT_VERBOSE, false);
if ($http_header) {
@curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
}
$result = @curl_exec($ch);
if (!$result) {
$this->_logs[] = $this->paypal->l('Send with CURL method failed ! Error:').' '.curl_error($ch);
if (curl_errno($ch)) {
die(var_dump(curl_error($ch)));
$this->_logPaypal(curl_error($ch));
}
sleep(1);
} else {
$this->_logs[] = $this->paypal->l('Send with CURL method successful');
break;
}
}
@curl_close($ch);
}
return $result ? $result : false;
}
调用这个 paypal nvp 接口时不时就报这个错误 OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to api-3t.paypal.com:443 ,或者 SSL connection timeout ,或者 OpenSSL/1.1.1u: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error ,是什么原因导致的啊,导致网站支付经常跳转失败
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.