最近接到一客户修改啦啦外卖小程序,什么问题呢,就是海报推广的时候 海报上没有二维码或小程序码,经过把客户的源码要过来发现,此客户应该是使用的破解版的,经过分析
在model/cloud.mod.php找到如下代码:
function cloud_w_wxapp_getanywxacode($path = "", $scene = "", $wxapp_type = "we7_wmall") { $params = cloud_w_build_wxapp_authorize_params(); if( is_error($params) ) { return $params; } $params["path"] = $path; $params["scene"] = $scene; $content = cloud_w_request("http:///weixin/xcx/getanywxacode.html", $params); if( is_error($content) ) { return $content; } $result = @json_decode($content, true); if( $result["errcode"] != 0 ) { if( strexists($result["errmsg"], "invalid page") ) { return error(-1, (string) $result["errcode"] . ": " . $result["errmsg"] . "。<br><span style='font-size: 20px; color: red'>请先确认小程序是否已通过微信官方审核并已经发布。说明:小程序二维码只有在小程序发布后才能生成!</span>"); } return error(-1, (string) $result["errcode"] . ": " . $result["errmsg"]); } if( $result["message"] && is_error($result["message"]) ) { return error(-1, (string) $result["message"]["message"]); } return $content; }
$content = cloud_w_request("http:///weixin/xcx/getanywxacode.html", $params); 这里的请求地址明显是错误的,整个cloud.mod.php里的请求地址都是错的,估计的为了屏蔽官方检测,但是这样就没法生成小程序码了,怎么办呢,那咱就不动这个文件了,直接修改文件model/qrcode.mod.php 找到qrcode_wxapp_build函数,替换成如下代码:
function qrcode_wxapp_build($params = array()) { $url = $params['url']; if (empty($url)) { return error(-1, '链接不能为空'); } $scene = $params['scene'];//print_r($params);exit; $mini_token_file = IA_ROOT.'/attachment/we7_wmall/mini_token.txt'; $mtf = explode('^',file_get_contents($mini_token_file)); $refresh_token = true; if($mtf && count($mtf)==2 && (time()-$mtf[1])<7200){ $refresh_token = false; } if($refresh_token){ $wxapp = get_plugin_config("wxapp"); $appid = $wxapp['basic']['key']; $secret = $wxapp['basic']['secret']; $r = ihttp_get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret); $t = json_decode($r['content'],true); $token = $t['access_token']; file_put_contents($mini_token_file,$token.'^'.time()); }else{ $token = $mtf[0]; } $data['scene'] = $scene; $request_url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$token; $content = ihttp_post($request_url,json_encode($data)); //print_r($response['content']); //exit; if (is_error($content)) { return $content; } $name = ifile_write($content['content'], $params['name']); return $name; }
ok,这就可以了,能正常生成了。
在此还是要劝说广大朋友使用正版,使用破解版的前期能发现问题还好,等运营起来 再发现问题就麻烦了~~