云片网短信发送

云片网短信发送示例

              //---------发送短信---------------
                        //模板发送的调用示例
                        String baozheng = “500”;
               String tel=“187xxxx2348”; String ENCODING
= "UTF-8"; String apikey = "xxxxxxxxxxxxxxxxxxxx";
              //短信模板id
long tpl_id=2301090; String result="1"; try {//"#code#"
                //模板参数设置
String tpl_value = URLEncoder.encode("#baozheng#",ENCODING) +"=" + URLEncoder.encode(baozheng,ENCODING);
                //发送请求 result
=JavaSmsApi.tplSendSms(apikey, tpl_id, tpl_value,tel); System.out.println(result);
                  //{"code":0,"msg":"发送成功","count":1,"fee":0.05,"unit":"RMB","mobile":"18702622348","sid":24192432464} JSONObject object
= JSON.parseObject(result); result=object.get("code").toString(); } catch (IOException e) { e.printStackTrace(); return "100"; } //------------------------------

猜你喜欢

转载自www.cnblogs.com/dztHome/p/9050692.html