当前位置: 首页 > news >正文

移动端网站开发软件做系统用什么网站

移动端网站开发软件,做系统用什么网站,网站域名优化,东莞工作招聘网最新招聘下面是一个Spring Boot集成腾讯云短信服务的详细示例#xff0c;包含配置和6个工具类#xff08;签名、模板、发送、统计、状态#xff09;#xff0c;采用YML配置#xff1a; 1. 添加Maven依赖 dependencygroupIdcom.tencentcloudapi/groupId包含配置和6个工具类签名、模板、发送、统计、状态采用YML配置 1. 添加Maven依赖 dependencygroupIdcom.tencentcloudapi/groupIdartifactIdtencentcloud-sdk-java/artifactIdversion3.1.270/version /dependency 2. application.yml 配置 tencent:sms:secret-id: AKIDz8krbsJ5**********EGTIOsecret-key: Gu5t9xGARN**********7vCKsdk-app-id: 1400****sign-name: 腾讯云测试region: ap-guangzhoutemplate-id: 1234567conn-timeout: 60write-timeout: 60 3. 配置读取类 Component ConfigurationProperties(prefix tencent.sms) public class TencentSmsConfig {private String secretId;private String secretKey;private String sdkAppId;private String signName;private String region;private String templateId;private int connTimeout;private int writeTimeout;// Getters and Setters } 4. 工具类实现 (1) 短信签名工具类 SmsSignUtils Component public class SmsSignUtils {private final SmsClient client;private final String sdkAppId;Autowiredpublic SmsSignUtils(TencentSmsConfig config) {Credential cred new Credential(config.getSecretId(), config.getSecretKey());HttpProfile httpProfile new HttpProfile();httpProfile.setConnTimeout(config.getConnTimeout());httpProfile.setWriteTimeout(config.getWriteTimeout());ClientProfile clientProfile new ClientProfile();clientProfile.setHttpProfile(httpProfile);this.client new SmsClient(cred, config.getRegion(), clientProfile);this.sdkAppId config.getSdkAppId();}// 添加短信签名public AddSmsSignResponse addSign(String signName, int signType, String document) throws Exception {AddSmsSignRequest req new AddSmsSignRequest();req.setSignName(signName);req.setSignType((long) signType);req.setDocumentType(new Long[]{5L}); // 5-三证合一req.setInternational(0L); // 国内短信req.setCertificateUrls(new String[]{document});return client.AddSmsSign(req);}// 删除短信签名public DeleteSmsSignResponse deleteSign(long signId) throws Exception {DeleteSmsSignRequest req new DeleteSmsSignRequest();req.setSignId(signId);return client.DeleteSmsSign(req);}// 获取签名状态public DescribeSmsSignListResponse getSignStatus(long[] signIds) throws Exception {DescribeSmsSignListRequest req new DescribeSmsSignListRequest();req.setSignIdSet(signIds);req.setInternational(0L);return client.DescribeSmsSignList(req);} } (2) 短信模板工具类 SmsTemplateUtils Component public class SmsTemplateUtils {private final SmsClient client;private final String sdkAppId;Autowiredpublic SmsTemplateUtils(TencentSmsConfig config) {Credential cred new Credential(config.getSecretId(), config.getSecretKey());HttpProfile httpProfile new HttpProfile();httpProfile.setConnTimeout(config.getConnTimeout());httpProfile.setWriteTimeout(config.getWriteTimeout());ClientProfile clientProfile new ClientProfile();clientProfile.setHttpProfile(httpProfile);this.client new SmsClient(cred, config.getRegion(), clientProfile);this.sdkAppId config.getSdkAppId();}// 创建模板public AddSmsTemplateResponse createTemplate(String templateName, String templateContent, int type) throws Exception {AddSmsTemplateRequest req new AddSmsTemplateRequest();req.setTemplateName(templateName);req.setTemplateContent(templateContent);req.setSmsType((long) type); // 0-普通短信 1-营销短信req.setInternational(0L);req.setRemark(系统自动创建);return client.AddSmsTemplate(req);}// 删除模板public DeleteSmsTemplateResponse deleteTemplate(long templateId) throws Exception {DeleteSmsTemplateRequest req new DeleteSmsTemplateRequest();req.setTemplateId(templateId);return client.DeleteSmsTemplate(req);}// 获取模板审核状态public DescribeSmsTemplateListResponse getTemplateStatus(long[] templateIds) throws Exception {DescribeSmsTemplateListRequest req new DescribeSmsTemplateListRequest();req.setTemplateIdSet(templateIds);req.setInternational(0L);return client.DescribeSmsTemplateList(req);} } (3) 短信发送工具类 SmsSendUtils Component public class SmsSendUtils {private final SmsClient client;private final String sdkAppId;private final String signName;Autowiredpublic SmsSendUtils(TencentSmsConfig config) {Credential cred new Credential(config.getSecretId(), config.getSecretKey());HttpProfile httpProfile new HttpProfile();httpProfile.setConnTimeout(config.getConnTimeout());httpProfile.setWriteTimeout(config.getWriteTimeout());ClientProfile clientProfile new ClientProfile();clientProfile.setHttpProfile(httpProfile);this.client new SmsClient(cred, config.getRegion(), clientProfile);this.sdkAppId config.getSdkAppId();}// 单发短信public SendSmsResponse sendSingleSms(String phone, String templateId, String[] params) throws Exception {SendSmsRequest req new SendSmsRequest();req.setPhoneNumberSet(new String[]{phone});req.setSmsSdkAppId(sdkAppId);req.setSignName(signName);req.setTemplateId(templateId);req.setTemplateParamSet(params);return client.SendSms(req);}// 群发短信public SendSmsResponse sendMultiSms(String[] phones, String templateId, String[] params) throws Exception {SendSmsRequest req new SendSmsRequest();req.setPhoneNumberSet(phones);req.setSmsSdkAppId(sdkAppId);req.setSignName(signName);req.setTemplateId(templateId);req.setTemplateParamSet(params);return client.SendSms(req);} } (4) 短信统计工具类 SmsStatisticsUtils Component public class SmsStatisticsUtils {private final SmsClient client;private final String sdkAppId;Autowiredpublic SmsStatisticsUtils(TencentSmsConfig config) {Credential cred new Credential(config.getSecretId(), config.getSecretKey());HttpProfile httpProfile new HttpProfile();httpProfile.setConnTimeout(config.getConnTimeout());httpProfile.setWriteTimeout(config.getWriteTimeout());ClientProfile clientProfile new ClientProfile();clientProfile.setHttpProfile(httpProfile);this.client new SmsClient(cred, config.getRegion(), clientProfile);this.sdkAppId config.getSdkAppId();}// 获取发送数据统计public SendStatusStatisticsResponse getSendStats(String startDate, String endDate) throws Exception {SendStatusStatisticsRequest req new SendStatusStatisticsRequest();req.setStartDateTime(startDate); // 格式: yyyyMMddreq.setEndDataTime(endDate);req.setSmsSdkAppId(sdkAppId);req.setLimit(100L);return client.SendStatusStatistics(req);}// 获取回执数据统计public CallbackStatusStatisticsResponse getCallbackStats(String startDate, String endDate) throws Exception {CallbackStatusStatisticsRequest req new CallbackStatusStatisticsRequest();req.setStartDateTime(startDate);req.setEndDataTime(endDate);req.setSmsSdkAppId(sdkAppId);return client.CallbackStatusStatistics(req);} } (5) 短信状态拉取工具类 SmsStatusUtils Component public class SmsStatusUtils {private final SmsClient client;private final String sdkAppId;Autowiredpublic SmsStatusUtils(TencentSmsConfig config) {Credential cred new Credential(config.getSecretId(), config.getSecretKey());HttpProfile httpProfile new HttpProfile();httpProfile.setConnTimeout(config.getConnTimeout());httpProfile.setWriteTimeout(config.getWriteTimeout());ClientProfile clientProfile new ClientProfile();clientProfile.setHttpProfile(httpProfile);this.client new SmsClient(cred, config.getRegion(), clientProfile);this.sdkAppId config.getSdkAppId();}// 拉取短信发送状态public PullSmsSendStatusResponse pullSendStatus(int limit) throws Exception {PullSmsSendStatusRequest req new PullSmsSendStatusRequest();req.setLimit((long) limit);req.setSmsSdkAppId(sdkAppId);return client.PullSmsSendStatus(req);}// 拉取短信回复状态public PullSmsReplyStatusResponse pullReplyStatus(int limit) throws Exception {PullSmsReplyStatusRequest req new PullSmsReplyStatusRequest();req.setLimit((long) limit);req.setSmsSdkAppId(sdkAppId);return client.PullSmsReplyStatus(req);} } 5. 使用示例 RestController RequestMapping(/sms) public class SmsController {Autowired private SmsSendUtils sendUtils;Autowired private SmsTemplateUtils templateUtils;// 发送验证码PostMapping(/sendCode)public String sendCode(RequestParam String phone) {try {String templateId 123456; // 验证码模板IDString code String.valueOf((int)(Math.random()*9000 1000));sendUtils.sendSingleSms(phone, templateId, new String[]{code, 5});return 发送成功;} catch (Exception e) {return 发送失败: e.getMessage();}}// 创建模板PostMapping(/createTemplate)public String createTemplate() {try {AddSmsTemplateResponse res templateUtils.createTemplate(验证码模板, 您的验证码是{1}有效期{2}分钟, 0);return 模板ID: res.getAddSmsTemplateStatus().getTemplateId();} catch (Exception e) {return 创建失败: e.getMessage();}} } 关键说明 认证信息SecretId/SecretKey在腾讯云控制台获取 短信签名需提前在控制台申请并通过审核 模板参数模板中的变量使用{1}、{2}格式 国际短信将International参数设为1 错误处理实际使用需添加更完善的异常处理 限流控制腾讯云默认限流300次/秒需注意控制发送频率 注意以上代码中的部分API调用如号码包操作做了简化处理实际使用时请参考腾讯云官方文档完善具体实现。
http://www.pierceye.com/news/707269/

相关文章:

  • 内外外贸购物网站建设网站顶部下拉广告
  • 深圳企业网站建设服务平台销售推广语
  • 做网站要什么资料百度网盘登录
  • 聚牛网站建设公司北京seo优化推广
  • 成都网站公司网站建设东莞大岭山电子厂
  • python建立简易网站网站界面设计的分类有哪几种
  • 网络规划师考哪些内容优化设计卷子答案
  • 邢台网站关键词优化wordpress弹窗下载
  • 晋城市企业网站腾讯qq官网登录入口
  • 怎么给网站在百度地图上做爬虫一家专门做灯的网站
  • 河南焦作有做网站开发的公司吗xampp安装wordpress
  • python购物网站开发流程图win淘宝客wordpress主题模板
  • 江苏省建设执业网站个人做淘宝客网站有哪些
  • 浙江省建设厅门户网站咨询公司是干什么的
  • 哪个网站上可以做初中数学题wordpress 网校插件
  • html写手机网站制作网页用什么语言
  • 一站式网站建设价格百度网站
  • 招商网站建设多少钱企业形象墙
  • 医疗设备响应式网站免费素材库
  • 服务器如何搭建php网站网页美工设计从入门到精通
  • 淘宝的网站建设情况做企业平台的网站有哪些
  • 深圳网站建设公司设计公司做网站排名有用吗
  • 企业营销型网站建设厂家 天堂资源地址在线官网
  • 编写这个网站模板要多少钱便宜做网站公司
  • asp企业网站源码下载网页制作基础教程田田田田田田田田
  • 网站标题title怎么写网站建设建设公司有哪些
  • 辽宁移动网站网站域名注册费用
  • 深圳建网站兴田德润专业电商店铺首页设计
  • 网站推广的工作内容芜湖做网站的客户
  • 求一些做里番的网站wordpress新闻快讯插件