未来无线发送短信接口文档

public Map sendMessage(SmsForm smsForm) throws IOException{
        String phone = smsForm.getPhone();
        String content = smsForm.getContent();
        // 数字签名,签名内容根据 “短信内容+客户密码”进行MD5编码后获得
        String sign = content + password;
        sign = Md5.getMd5(sign.getBytes("UTF-8"));
        //长号码,选填
        String sp_code = "";
        // 是否需要状态报告
        String need_report = "yes";
        // 业务标识,选填,由客户自行填写不超过20位的数字
        String uid = "";
        String json_send_sms = "{\"cust_code\":\"" + account + "\",\"sp_code\":\"" + sp_code + "\",\"content\":\"" + content +
                  "\",\"destMobiles\":\"" + phone + "\",\"uid\":\"" + uid + "\",\"need_report\":\"" + need_report + "\",\"sign\":\"" + sign + "\"}";
        URL urls = new URL(url);
        HttpURLConnection httpURLConnection = (HttpURLConnection) urls.openConnection();
        httpURLConnection.setRequestMethod("POST");
        httpURLConnection.setDoOutput(true);
        httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        OutputStream out = httpURLConnection.getOutputStream();
        out.write(json_send_sms.getBytes("UTF-8"));
        LOG.info("send msg:\t"+json_send_sms);
        InputStream inputStream = null;
        InputStreamReader inputStreamReader = null;
        BufferedReader reader = null;
        StringBuffer resultBuffer = new StringBuffer();
        String tempLine = null;
        try {
              inputStream = httpURLConnection.getInputStream();
              inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
              reader = new BufferedReader(inputStreamReader);
              while ((tempLine = reader.readLine()) != null) {
                  resultBuffer.append(tempLine);
              }
              LOG.info("recv msg:\t"+resultBuffer.toString());
        } catch (Exception e) {
              throw e;
        } finally {
              if (reader != null) {
                  reader.close();
              }
              if (inputStreamReader != null) {
                  inputStreamReader.close();
              }
              if (inputStream != null) {
                  inputStream.close();
              }
              httpURLConnection.disconnect();
        }
      JSONObject jasonObject = JSONObject.parseObject(resultBuffer.toString());
      Map map = jasonObject;

      Map<String,Object> message = new HashMap<>();
      if(map.get("respCode")!=null && "0".equals(map.get("respCode"))){
            JSONArray jasonArray = (JSONArray) map.get("result");
            JSONObject jasonObject2 = (JSONObject) jasonArray.get(0);
            Map result2 = jasonObject2;
            if(result2.get("code")!=null && !"0".equals(result2.get("code"))){
                message.put("errors",map);
            }else {
                message.put("datas",map);
            }
      }else {
          message.put("outcome",map);
      }
      return message;
  }

接口文档参考链接:
http://43.243.130.33:8099/support/http-3.0.jsp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值