
这是封装的方法:
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 ,是什么原因导致的啊,导致网站支付经常跳转失败
1 weijancc 2023-06-20 17:17:39 +08:00 换境外服务器, 目前最快的是阿里云香港, 轻量服务器才 34/月 |
2 rivercherdeeeeee OP @weijancc 就是境外服务器啊 |
3 yinmin 2023-06-20 17:23:38 +08:00 curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); |