admin 发表于 2020-7-10 15:35:43

Discuz!设置微信支付curl出错及错误码解决方案




1. curl错误码6出现场景
PHP Fatal error:Uncaught exception 'WxPayException' with message 'curl出错,错误码:6' in WxpayAPI_php_v3/lib/WxPay.Api.php:565Stack trace:#0 WxpayAPI_php_v3/lib/WxPay.Api.php(62): WxPayApi::postXmlCurl('<xml><appid><![...', 'https://api.mch...', false, 6)#1 WxpayAPI_php_v3/cyzjqpzf/jsapi.php(83): WxPayApi::unifiedOrder(Object(WxPayUnifiedOrder))#2 {main}thrown in WxpayAPI_php_v3/lib/WxPay.Api.php on line 565 PHP Fatal error:Uncaught exception 'WxPayException' with message 'curl出错,错误码:6' in WxpayAPI_php_v3/lib/WxPay.Api.php:565Stack trace:#0 WxpayAPI_php_v3/lib/WxPay.Api.php(62): WxPayApi::postXmlCurl('<xml><appid><![...', 'https://api.mch...', false, 6)#1 WxpayAPI_php_v3/cyzjqpzf/jsapi.php(83): WxPayApi::unifiedOrder(Object(WxPayUnifiedOrder))#2 {main}thrown in WxpayAPI_php_v3/lib/WxPay.Api.php on line 565

原因分析CURLE_COULDNT_RESOLVE_HOST(6)
无法解析主机。给定的远程主机没有得到解决。解决方法dns解析不了微信的域名,检查本地的dns服务器,或者在本地强制解析
vietc/hosts添加下面内容101.227.143.34 open.weixin.qq.com101.226.90.149 api.mch.weixin.qq.com101.226.90.58 api.weixin.qq.com


2. curl错误码60出现场景如下是运行微信支付测试代码时出错代码:
Fatal error: Uncaught exception ‘WxPayException‘ with message ‘curl出错,错误码:60‘ in C:\wwwroot\fangbei\lib\WxPay.Api.php:564 Stack trace: #0 C:\wwwroot\fangbei\lib\WxPay.Api.php(62): WxPayApi::postXmlCurl(‘<xml><appid><![...‘, ‘https://api.mch...‘, false, 6) #1 C:\wwwroot\fangbei\pay\jsapi.php(36): WxPayApi::unifiedOrder(Object(WxPayUnifiedOrder)) #2 {main} thrown in C:\wwwroot\fangbei\lib\WxPay.Api.php on line 564
原因分析证书校验失败解决方法第538行curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验
修改为curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);//严格校验


3. curl错误码58出现场景Fatal error: Uncaught exception 'WxPayException' with message 'curl出错,错误码:58' in C:\wamp\www\API\lib\WxPay.Api.php on line 565 WxPayException: curl出错,错误码:58 in C:\wamp\www\API\lib\WxPay.Api.php on line 565 证书路径正...
原因分析证书路径错误解决方法windows服务器上证书路径使用绝对路径。curl_setopt($ch, CURLOPT_SSLCERT, dirname(__FILE__).'cert'.DIRECTORY_SEPARATOR.'apiclient_cert.pem');curl_setopt($ch, CURLOPT_SSLKEY, dirname(__FILE__).'cert'.DIRECTORY_SEPARATOR.'apiclient_key.pem');curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'cert'.DIRECTORY_SEPARATOR.'rootca.pem');
Linux上使用相对路径curl_setopt($ch, CURLOPT_SSLCERT, 'cert'.DIRECTORY_SEPARATOR.'apiclient_cert.pem');curl_setopt($ch, CURLOPT_SSLKEY, 'cert'.DIRECTORY_SEPARATOR.'apiclient_key.pem');curl_setopt($ch, CURLOPT_CAINFO, 'cert'.DIRECTORY_SEPARATOR.'rootca.pem');


4. curl错误码52出现场景原因分析证书路径错误解决方法方法同错误码58

5. curl错误码77出现场景略原因分析证书路径错误解决方法方法同错误码58

6. curl错误码28出现场景支付curl出错,错误码:28/wxpay_native/WxPay.Api.php LINE: 563/wxpay_native/WxPay.Api.php(61):WxPayApi::postXmlCurl(' #1
原因分析CURLE_OPERATION_TIMEDOUT(28)操作超时。根据条件达到指定的超时期间。
解决方法服务器网络和微信服务器连接时间太久,网速问题。或者将超时时间设置长一些。比如将超时时间改为60function postXmlCurl($xml, $url, $useCert = false, $second = 60)

页: [1]
查看完整版本: Discuz!设置微信支付curl出错及错误码解决方案

创宇盾启航版免费网站防御网站加速服务