ホームページ  >  記事  >  バックエンド開発  >  WeChatのワンタイムサブスクリプションメッセージアクセス問題の分析

WeChatのワンタイムサブスクリプションメッセージアクセス問題の分析

小云云
小云云オリジナル
2018-03-06 09:55:051896ブラウズ

この記事では、主に 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();
    }
handleIntent() が false を返し、onResp メソッドを呼び出すことができません。 その理由は、上記の respType = null であるためですが、extInfo にデータがあることがわかり、それが可能です。 wx_internal_resptype =subscribemessage であることが分かりました。

ここで WXApiImplV10.class を見てください。コードの一部は次のとおりです:


つまり、ここでは respType=subscribemessage ですが、上で解析されて null になります。キー コードは次のとおりです。

その後、ここの extInfo 文字列の先頭に「?」がないことに気付きました。そのため、extInfo を Uri に解析した後、指定された「wx_internal_resptype」属性が見つかりません。したがって、ページは次のステップに進めずに WXEntryActivity ページでスタックしてしまいます。WeChat 開発チームができるだけ早くこれに対処できることを願っています。

以上がWeChatのワンタイムサブスクリプションメッセージアクセス問題の分析の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。