위챗 일회성 구독 메시지 접근 문제 분석

小云云
풀어 주다: 2023-03-20 19:14:01
원래의
1896명이 탐색했습니다.

이 글은 주로 WeChat 일회성 구독 메시지 액세스 문제에 대한 분석을 공유합니다. 일회성 구독 메시지를 보낼 수 있는 권한:

 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 = 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
로그인 후 복사

handleIntent()가 false를 반환하고 onResp 메서드를 호출할 수 없습니다. 그 이유는 위의 respType = null 때문인데 extInfo에 데이터가 있는 것으로 확인되어 그럴 수 있습니다. wx_internal_resptype =subscribemessage를 확인하세요.

여기서 WXApiImplV10.class를 보면 코드의 일부는 다음과 같습니다.


여기서는 respType=subscribemessage이지만 위에서 구문 분석되어 null이 됩니다.


그런 다음 여기에 있는 extInfo 문자열의 시작 부분에 "?"가 누락되어 extInfo를 Uri로 구문 분석한 후 지정된 "wx_internal_resptype" 속성을 찾을 수 없다는 것을 깨달았습니다. 따라서 해당 페이지는 다음 단계로 진행되지 않고 WXEntryActivity 페이지에서 멈춥니다. WeChat 개발팀에서 최대한 빨리 처리할 수 있기를 바랍니다.

위 내용은 위챗 일회성 구독 메시지 접근 문제 분석의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!