Warning: curl_setopt() expects parameter 2 to be long, string given in D:\wwwroot\weixinpaytest\pay\WxPay.JsApiPay.php on line 99
Fatal error: Uncaught exception ‘WxPayException‘ with message ‘curl出错,错误码:60‘ in D:\wwwroot\weixinpaytest\lib\WxPay.Api.php:564 Stack trace: #0 D:\wwwroot\weixinpaytest\lib\WxPay.Api.php(62):
WxPayApi::postXmlCurl(‘<xml><appid><![...‘, ‘https://api.mch...‘, false, 6) #1 D:\wwwroot\weixinpaytest\pay\jsapi.php(36):
WxPayApi::unifiedOrder(Object(WxPayUnifiedOrder)) #2 {main} thrown in D:\wwwroot\weixinpaytest\lib\WxPay.Api.php on line 564
Warning: curl_setopt() expects parameter 2 to be long, string given in D:\wwwroot\weixinpaytest\pay\WxPay.JsApiPay.php on line 99
找到WxPay.JsApiPay.php文件的99行,curl_setopt($ch, CURLOP_TIMEOUT, 30);
微信团队example代码里少了一个“T”,正确代码应该是 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
第二个问题:
Fatal error: Uncaught exception ‘WxPayException‘ with message ‘curl出错,错误码:60‘ in D:\wwwroot\weixinpaytest\lib\WxPay.Api.php:564 Stack trace: #0 D:\wwwroot\weixinpaytest\lib\WxPay.Api.php(62):
WxPayApi::postXmlCurl(‘<xml><appid><![...‘, ‘https://api.mch...‘, false, 6) #1 D:\wwwroot\weixinpaytest\pay\jsapi.php(36):
WxPayApi::unifiedOrder(Object(WxPayUnifiedOrder)) #2 {main} thrown in D:\wwwroot\weixinpaytest\lib\WxPay.Api.php on line 564
修改文件WxPay.Api.php,具体如下:
第537行
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验
to
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);//严格校验2
目录不要超过三级
例如:
http://wl.xxx.com/wxpay/example/ 可以
http://wl.xxx.com/wxpay/example/test/ 不可以
一般这样写
ecshop :http://wl.xxx.com/mobile/ --后斜杠一定不要忘了写
ThinkPHP :http://wl.xxx.com/ --后斜杠一定不要忘了写
把demo适当封装后,调用的时候直接输出支付按钮即可
问题原因:时间戳必须是字符串,因为它要拼接到json里面
解决办法:
找到Wxpay.JsApiPay.php 大概 76行
$jsapi->SetTimeStamp($timeStamp);
改为
$jsapi->SetTimeStamp("$timeStamp");
现在,坑填平了,接下来就靠你自己了……