微信支付问题

1、出现redirect_uri参数错误是因为公众号后台授权回调页面没有填写域名,详见http://jingyan.baidu.com/article/91f5db1b3659811c7e05e357.html

2、出现Notice: Use of undefined constant CURLOP_TIMEOUT - assumed 'CURLOP_TIMEOUT' in D:\PHP\htdocs\pay\wx\WxPayPubHelper\WxPayPubHelper.php on line 823
     Warning: curl_setopt() expects parameter 2 to be long, string given in D:\PHP\htdocs\pay\wx\WxPayPubHelper\WxPayPubHelper.php on line 823是因为微信团队给的代码的问题

WxPayPubHelper\WxPayPubHelper.php这个文件:

    public function GetOpenidFromMp($code)  
    {  
        $url = $this->__CreateOauthUrlForOpenid($code);  
        //初始化curl  
        $ch = curl_init();  
        //设置超时  
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);//这里少了个T【CURLOP_TIMEOUT , CURLOPT_TIMEOUT】  
        curl_setopt($ch, CURLOPT_URL, $url);  
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);  
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);  
        curl_setopt($ch, CURLOPT_HEADER, FALSE);  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  
        if(WxPayConfig::CURL_PROXY_HOST != "0.0.0.0"   
            && WxPayConfig::CURL_PROXY_PORT != 0){  
            curl_setopt($ch,CURLOPT_PROXY, WxPayConfig::CURL_PROXY_HOST);  
            curl_setopt($ch,CURLOPT_PROXYPORT, WxPayConfig::CURL_PROXY_PORT);  
        }  
        //运行curl,结果以jason形式返回  
        $res = curl_exec($ch);  
        curl_close($ch);  
        //取出openid  
        $data = json_decode($res,true);  
        $this->data = $data;  
        $openid = $data['openid'];  
        return $openid;  
    }  

更改以后就可以正常运行了

posted @ 2017-03-30 14:17  郁冬  阅读(292)  评论(0编辑  收藏  举报