日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

阿里巴巴发送短信接口的使用

發布時間:2025/3/19 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 阿里巴巴发送短信接口的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、與阿里巴巴談個生意,申請阿里巴巴的短信服務。這個我就不寫了,按照阿里巴巴官網的申請步驟,一步一步,不會了打阿里巴巴的客服電話。
2、復制一下代碼:

/** * Copyright ? 2019 eSunny Info. Tech Ltd. All rights reserved.* 功能描述:* @Package: com.newtouch.modules.sys.utils * @author: admin * @date: 2019年5月17日 下午3:13:23 */ package com.newtouch.modules.sys.utils;import com.aliyuncs.CommonRequest; import com.aliyuncs.CommonResponse; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ServerException; import com.aliyuncs.http.MethodType; import com.aliyuncs.profile.DefaultProfile;/*** Copyright: Copyright (c) 2019 LanRu-Caifu* * @ClassName: SendSMSUtils.java* @Description: alibaba發送短信* @version: v1.0.0* @author: admin* @date: 2019年5月17日 下午3:13:23*/ public class SendSMSUtils {private final static String accessKeyId = "";// 你的accessKeyIdprivate final static String accessKeySecret = "";// 你的accessKeySecretprivate final static String signName = "";你的signNamepublic static String sendSMS(String phoneNumber, String templateParam, String templateCode) {DefaultProfile profile = DefaultProfile.getProfile("default", accessKeyId, accessKeySecret);IAcsClient client = new DefaultAcsClient(profile);CommonRequest request = new CommonRequest();//request.setProtocol(ProtocolType.HTTPS);request.setMethod(MethodType.POST);request.setDomain("dysmsapi.aliyuncs.com");request.setVersion("2017-05-25");request.setAction("SendSms");request.putQueryParameter("SignName", signName);request.putQueryParameter("PhoneNumbers", phoneNumber);request.putQueryParameter("TemplateCode", templateCode);request.putQueryParameter("TemplateParam", templateParam);CommonResponse response = null;try {response = client.getCommonResponse(request);} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {e.printStackTrace();}System.out.println(response.getData());return response.getData();}}

3、調用接口:
String templateParam = “{name:”"+applyOnline.getName()+""}";
SendSMSUtils.sendSMS(applyOnline.getMobilephone(), templateParam, “你的templateCode”);
**注:**上面穿的參數,除了電話和參數是你自己的,其他的都是在阿里巴巴的短信平臺生成的。要使用這個服務,你的服務必須能訪問外網,不能訪問外網,就要考慮其他方式實現。

總結

以上是生活随笔為你收集整理的阿里巴巴发送短信接口的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。