• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

微信一次性订阅消息接入问题解析

php 搞代码 3年前 (2022-01-22) 21次浏览 已收录 0个评论

本文主要和大家分享微信一次性订阅消息接入问题解析,环境都已经接入,发送 一次性订阅消息 授权:

 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, "发送请求结束");

在授权页面的回调中做简单的处理:

@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();    }

在打开的调试打印中显示:

03-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleIntent, cmd = 403-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXMediaMessage: pathOldToNew, oldPath = com.tencent.mm.sdk.openapi.WXAppExtendObject03-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=88903-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType, respType = null<strong style="color:transparent">9来源gaodai#ma#com搞@代~码$网</strong>搞gaodaima代码03-05 17:46:00.967 10706-10706/com.xxx E/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType fail, respType is null

handleIntent()的时候,返回的是false,也没法调用onResp方法,其中的原因是因为上面的respType = null,但是上面发现extInfo是有数据的,并且可以看出wx_internal_resptype=subscribemessage。

这边查看WXApiImplV10.class,部分代码如下:

也就是说,这边的respType=subscribemessage,但是上面解析出来变成了null, 其中关键的代码是:

然后才明白,这边的extInfo字符串的起始处少了一个“?”,所以把extInfo解析成Uri后,就找不到指定的“wx_internal_resptype”属性了。所以页面会卡在WXEntryActivity页面没有进行下一步的操作,这边希望微信开发团队可以尽早处理!

以上就是微信一次性订阅消息接入问题解析的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:微信一次性订阅消息接入问题解析

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址