34yhtee 发表于 2016-8-26 09:39:10

PHP读取微信超时,'curl出错,错误码:28'

PHP读取微信认证超时,错误如下:

1548#0: *137 FastCGI sent in stderr: "PHP message: PHP Fatal error:Uncaught exception 'WxPayException' with message 'curl出错,错误码:28' in /home/cat/html/releases/20160825025148/lib/WxPay.Api.php:566

错误代码28表示超时,有的网站说吧 second更改为60 ,如下
private static function postXmlCurl($xml, $url, $useCert = false, $second = 60)
{
$ch = curl_init();
//设置超时
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
……………………

经过小编尝试根本不管用

正确的做法应该是更改函数 unifiedOrder 的参数timeout的值,默认是6,增大为你可以使用的状态为止
public static function unifiedOrder($inputObj, $timeOut = 6)
        {
                $url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
                //检测必填参数
                if(!$inputObj->IsOut_trade_noSet()) {
                        throw new WxPayException("缺少统一支付接口必填参数out_trade_no!");
                }else if(!$inputObj->IsBodySet()){
                        throw new WxPayException("缺少统一支付接口必填参数body!");
                }else if(!$inputObj->IsTotal_feeSet()) {
                        throw new WxPayException("缺少统一支付接口必填参数total_fee!");
                }else if(!$inputObj->IsTrade_typeSet()) {
                        throw new WxPayException("缺少统一支付接口必填参数trade_type!");
                }



页: [1]
查看完整版本: PHP读取微信超时,'curl出错,错误码:28'