• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
axuuww
博客园    首页    新随笔    联系   管理    订阅  订阅
NutzBoot的短信发送(平台接口转发)
public NutMap doSmsSendPost(String content, String mobile) {
        try {
            Base_sms_config config = baseSmsConfigService.getConfig();
            if (Lang.isNotEmpty(config) && !config.isDisabled()) {
                Map<String, Object> params = new HashMap<>();
                params.put("LoginName", config.getAccount());
                params.put("Pwd", config.getPassword());
                params.put("FeeType", "2");
                params.put("Mobile", mobile);
                params.put("Content", content);
                params.put("SignName", conf.get("sms.request.sign", "【智慧守护家】"));
                Header header = Header.create();
                String url = config.getServerAddress();
                Request request = Request.create(url, Request.METHOD.GET, params, header);
                Response re = Sender.create(request).setTimeout(10 * 1000).send();
                if (re.isOK()) {
                    String result = Strings.sNull(re.getContent());
                    if (result.startsWith("OK")) {
                        String[] strings = Strings.splitIgnoreBlank(result, "\\|");
                        NutMap nutMap = NutMap.NEW();
                        nutMap.setv("msgId", strings[1]);
                        nutMap.setv("code", 0);
                        return nutMap;
                    } else {
                        NutMap nutMap = NutMap.NEW();
                        int number = Integer.parseInt(result);
                        switch (number) {
                            case -21:
                                nutMap.setv("msg", "语音模板显示号码未设置");
                                break;
                            case -22:
                                nutMap.setv("msg", "语音模板ID不存在");
                                break;
                            case -23:
                                nutMap.setv("msg", "语音模板不存在");
                                break;
                            case -24:
                                nutMap.setv("msg", "语音模板参数不匹配");
                                break;
                            case -103:
                                nutMap.setv("msg", "IP未导白");
                                break;
                        }
                        nutMap.setv("code", -100);
                        return nutMap;
                    }
                }
            }
            baseSmsConfigService.clearCache();
            return NutMap.NEW().setv("code", -100);
        } catch (HttpException e) {
            log.error(e);
            return NutMap.NEW().setv("code", -100);
        }
    }
posted on 2024-02-05 16:30  雁来月~十一  阅读(10)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3