Analysis of WeChat one-time subscription message access problem

小云云
Release: 2023-03-20 19:14:01
Original
1960 people have browsed it

This article mainly shares with you the analysis of WeChat one-time subscription message access issues. The environment has been accessed. Authorization to send one-time subscription messages:

 final IWXAPI api = WXAPIFactory.createWXAPI(SettingActivity.this, response.getAppId());
                // 将该app注册到微信
                api.registerApp(ServerUrls.WEIXIN_APP_ID);
                Log.i("20180228", "come to send request with subscribeMessage....");
                SubscribeMessage.Req req = new SubscribeMessage.Req();
                req.templateID = response.getTemplateId();
                req.scene = 889;
//                req.reserved = response.getReserved();
                Log.i("20180228", "req.appId: "+response.getAppId());
                Log.i("20180228", "req.templateId: "+req.templateID);
//                Log.i("20180228", "req.scene: "+req.scene);
//                Log.i("20180228", "req.reserved: "+req.reserved);
                Log.i("20180228", "before send request: "+req.toString());
                boolean sendResult = api.sendReq(req);
                Log.i("20180228", "after send request: "+sendResult);
                ToastUtils.show(SettingActivity.this, "发送请求结束");
Copy after login

Do simple processing in the callback of the authorization page:

@Override
    public void onResp(BaseResp resp) {
        Log.i("20180228", "here come to the resp with wechat request: "+resp.toString());
        Log.i("20180228", "here come to the resp with wechat errCode: "+resp.errCode);
        Log.i("20180228", "here come to the resp with wechat errStr: "+resp.errStr);
        Log.i("20180228", "here come to the resp with wechat openId: "+resp.openId);
        Log.i("20180228", "here come to the resp with wechat type: "+resp.getType());
        ToastUtils.show(this, "openId: "+resp.openId);
        if(resp.getType() == ConstantsAPI.COMMAND_SUBSCRIBE_MESSAGE){
            Log.i("20180305", "here come to resp method successful....");
        }
//        if (resp.getType() == ConstantsAPI.COMMAND_SENDAUTH && resp.errCode == BaseResp.ErrCode.ERR_OK){
//            ToastUtils.show(this, "request auth here ....");
//            String openId = resp.openId;
//            int errCode = resp.errCode;
//            String errString = resp.errStr;
//
//            new UserManager(this).bidnWXRSS(openId, new SimpleCallback<ApiResponse>() {
//                @Override
//                public void onSuccess(ApiResponse response) {
//                    ToastUtils.show(WXEntryActivity.this, "绑定成功!");
//                    finish();
//                }
//            });
//        }


        finish();
    }
Copy after login

It is displayed in the open debug print:

03-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleIntent, cmd = 4
03-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXMediaMessage: pathOldToNew, oldPath = com.tencent.mm.sdk.openapi.WXAppExtendObject
03-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType, extInfo = wx_internal_resptype=subscribemessage&openid=oerX_woJRjvv8NzuUJHcKJe5PzwU&template_id=H0tXdBxs_ea5bVofycFBUPZl3hRgLWHxJIVBEYhSnxQ&action=confirm&reserved=null&scene=889
03-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType, respType = null
03-05 17:46:00.967 10706-10706/com.xxx E/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType fail, respType is null
Copy after login

handleIntent() returns false, and the onResp method cannot be called. The reason is because the above respType = null, But it was found above that extInfo has data, and it can be seen that wx_internal_resptype=subscribemessage.

Look at WXApiImplV10.class here, part of the code is as follows:


That is to say, respType=subscribemessage here, but it is parsed above It became null, and the key code is:


# Then I realized that there is a "?" missing from the beginning of the extInfo string here. So after parsing extInfo into Uri, the specified "wx_internal_resptype" attribute cannot be found. Therefore, the page will be stuck on the WXEntryActivity page without proceeding to the next step. I hope the WeChat development team can handle it as soon as possible!

The above is the detailed content of Analysis of WeChat one-time subscription message access problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template