阿里短信单发,批量发送_如何用阿里小号发短信

阿里短信单发,批量发送_如何用阿里小号发短信1.导入<!–阿里云短信–><dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-core</artifactId>&lt…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

1.导入

        <!--阿里云短信-->
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>4.0.3</version>
        </dependency>

Jetbrains全家桶1年46,售后保障稳定

单条发送

	/**
	 * 阿里云短信发送
	 */
	public  String sendALMSM(String content, String mobile,String temNo) {
		DefaultProfile profile = DefaultProfile.getProfile(PropertiesUtils.getInstance().getProperty("regionId"), PropertiesUtils.getInstance().getProperty("accessKeyId"), PropertiesUtils.getInstance().getProperty("secret"));
		IAcsClient client = new DefaultAcsClient(profile);

		CommonRequest request = new CommonRequest();
		request.setMethod(MethodType.POST);
		request.setDomain("dysmsapi.aliyuncs.com");
		request.setVersion("2017-05-25");
		request.setAction("SendSms");
		request.putQueryParameter("RegionId", PropertiesUtils.getInstance().getProperty("regionId"));
		request.putQueryParameter("PhoneNumbers", mobile); //接收短信的手机号码。
		request.putQueryParameter("SignName", PropertiesUtils.getInstance().getProperty("signName"));//短信签名名称
		request.putQueryParameter("TemplateCode", temNo);//短信模板ID
		request.putQueryParameter("TemplateParam", content);//短信模板变量对应的实际值,JSON格式 {"code":"1111"}

		CommonResponse response= null;
		try {
			response = client.getCommonResponse(request);
			System.out.println("短信接口返回的数据----------------");
			System.out.println(response.getData());

		} catch (ServerException e) {
			e.printStackTrace();
		} catch (ClientException e) {
			e.printStackTrace();
		}
		return response.getData();
	}

 

批量发送

public static String sendALMSMPl(String mobile,String SignNameJson,String temNo,String content) {
		DefaultProfileprofile = DefaultProfile.getProfile("cn-hangzhou", "", "");
		IAcsClient client = new DefaultAcsClient(profile);

	        CommonRequest request = new CommonRequest();
	        request.setMethod(MethodType.POST);
	        request.setDomain("dysmsapi.aliyuncs.com");
	        request.setVersion("2017-05-25");
	        request.setAction("SendBatchSms");
	        request.putQueryParameter("RegionId", "cn-hangzhou");
	        request.putQueryParameter("PhoneNumberJson", mobile);
	        request.putQueryParameter("SignNameJson", SignNameJson);
	        request.putQueryParameter("TemplateCode", temNo);
	        request.putQueryParameter("TemplateParamJson", content);
	        CommonResponse response= null;
	        try {
	             response = client.getCommonResponse(request);
	            System.out.println(response.getData());
	        } catch (ServerException e) {
	            e.printStackTrace();
	        } catch (ClientException e) {
	            e.printStackTrace();
	        }
	        return response.getData();
	}

 

                      

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/226759.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 大学生英语竞赛常考词汇汇总_全国大学生英语竞赛难吗

    大学生英语竞赛常考词汇汇总_全国大学生英语竞赛难吗abbreviation节略,缩写,缩短abidevi遵守,vt忍受absent不在意的abolishvt废除,取消abstracta理论上的,n抽象accessory同谋a附属的accord调和,符合,协议acknowledgevt承认,告知收到acquaintvt使认识,使了解adherevi黏附,追随,坚持adjoinvt贴近,毗连,靠近adjustablea.可调整的,可校准的administrationn局(或署、处等)

    2022年8月24日
    3
  • EnableEventValidation=”false”「建议收藏」

    EnableEventValidation=”false”「建议收藏」出现这种原因在页面开头添加上EnableEventValidation=”false”

    2022年7月13日
    19
  • v4l2驱动框架(Windows驱动开发技术详解)

    环境:OS:Ubuntu16.04(Win10hypev)KernelVersion:3.13.0-24-generic这里终极目标是注册一个/dev/video0的设备,再通过一个应用程序去读取它:#include&lt;linux/module.h&gt;#include&lt;linux/videodev2.h&gt;#include&lt;media/v…

    2022年4月12日
    195
  • kfold交叉验证k越大_内部交叉验证

    kfold交叉验证k越大_内部交叉验证交叉验证的原理放在后面,先看函数。设X是一个9*3的矩阵,即9个样本,3个特征,y是一个9维列向量,即9个标签。现在我要进行3折交叉验证。执行kFold=KFold(n_splits=3):其中KFold是一个类,n_split=3表示,当执行KFold的split函数后,数据集被分成三份,两份训练集和一份验证集。执行index=kFold.split(X=X):index是一个生成器…

    2022年9月20日
    0
  • ubuntu安装图形化界面_ubuntu 安装桌面

    ubuntu安装图形化界面_ubuntu 安装桌面系统安装的Ubuntu16.04,默认的桌面的系统不是很习惯,特意安装了xfce4桌面系统。设置开机启动项从Xfce桌面菜单中选择"SettingsManager"(设置管理器)-&gt;Settings"(设置)窗口-&gt;SessionandStartup"(会话和启动)图标。1各种桌面环境下设置开机自启动应用程序的方法↩︎…

    2022年10月29日
    0
  • Makefile详解

    Makefile详解一、Makefile规则格式Makefile是由一系列的单一规则指令组合起来:目标XX1:依赖文件<TAB>命令1<TAB>命令2目标XX2:依赖文件<TAB>命令1<TAB>命令2……指令1:命令1命令2指令2:命令1命令2……示例:Tag:a….

    2022年7月19日
    10

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号