解决啦啦外卖小程序无法生成海报推广码

最近接到一客户修改啦啦外卖小程序,什么问题呢,就是海报推广的时候 海报上没有二维码或小程序码,经过把客户的源码要过来发现,此客户应该是使用的破解版的,经过分析

在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,这就可以了,能正常生成了。

在此还是要劝说广大朋友使用正版,使用破解版的前期能发现问题还好,等运营起来 再发现问题就麻烦了~~

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值