spring boot 整合 云之讯 demo
生活随笔
收集整理的這篇文章主要介紹了
spring boot 整合 云之讯 demo
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
spring boot 整合 云之訊 demo
項目結構:
---恢復內容開始---
package com.zhourong.controller;import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate;import com.zhourong.dto.SmsDto; import com.zhourong.utils.Result; import com.zhourong.vo.SmsVo;@RestController @RequestMapping("/sms/") public class SmsController {private final String appid = "6d5ea3e7964341058f0cd1b31799eb27";private final String sid = "b3cf37114ad3e0f61d66d5317306af70";private final String token = "1a1e13a677e25df8ceadb8dd100d2fd3";private final String templateid = "413092";@Autowiredprivate RestTemplate restTemplate;@RequestMapping("/send")@ResponseBodypublic Result<SmsVo> send() {String url = "https://open.ucpaas.com/ol/sms/sendsms";SmsDto sms = new SmsDto(); String code = RandomStringUtils.randomNumeric(4); sms.setAppid(appid);sms.setMobile("18821962348");sms.setSid(sid);sms.setTemplateid(templateid);sms.setToken(token);sms.setParam(code);ResponseEntity<SmsVo> smsVo = restTemplate.postForEntity(url,sms, SmsVo.class);return new Result(200,"發送成功",smsVo);} }項目結構:
?
?
直接用。
git:https://gitee.com/xxoo0_297/SMS.git
?
---恢復內容結束---
posted on 2018-12-21 22:55 zhouixi 閱讀(...) 評論(...) 編輯 收藏轉載于:https://www.cnblogs.com/1-Admin/p/10159423.html
總結
以上是生活随笔為你收集整理的spring boot 整合 云之讯 demo的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [plutus666原创]星图模拟软件-
- 下一篇: 2018AHU新生赛Panelatta与