1、出现redirect_uri参数错误是因为公众号后台授权回调页面没有填写域名,详见http://jingyan.baidu.com/article/91f5db1b3659811c7e05e357.html
2、出现Notice: Use of undefined constant CURLOP_TIMEOUT - assumed 'CURLOP_TIMEOUT' in D:PHPhtdocspaywxWxPayPubHelperWxPayPubHelper.php on line 823
Warning: curl_setopt() expects parameter 2 to be long, string given in D:PHPhtdocspaywxWxPayPubHelperWxPayPubHelper.php on line 823是因为微信团队给的代码的问题
WxPayPubHelperWxPayPubHelper.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; }
更改以后就可以正常运行了