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

阿里短信单发,批量发送_如何用阿里小号发短信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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • goland2021 破解激活码[在线序列号]

    goland2021 破解激活码[在线序列号],https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月18日
    269
  • 御用导航提示页面_终实现微信位置发送到汽车导航 越用越好用

    御用导航提示页面_终实现微信位置发送到汽车导航 越用越好用我们使用微信,其中一个非常好用的功能就是发送位置。在朋友聚会或者去朋友家做客时,只需朋友发送一个微信用微信位置,我们就非常清楚的得知目的地,直接把这个位置推送给手机里的导航软件,并发起导航。然而对于习惯使用中控屏导航的车友来说,这个过程脱节了。微信位置只能使用手机导航,不能直接推送到车载导航。手动输入,无疑更加烦躁,担心输错,还要确认好几次。在最新的高德地图车机版中,我们留意到更新中“手…

    2022年5月30日
    320
  • murmurhash3 java_MurMurHash3

    murmurhash3 java_MurMurHash3packageutil.hash;/***TheMurmurHash3algorithmwascreatedbyAustinApplebyandplacedinthepublicdomain.*ThisjavaportwasauthoredbyYonikSeeleyandalsoplacedintothepublicdomain.*…

    2022年10月19日
    2
  • 了解匹配表

    了解匹配表

    2021年8月4日
    66
  • 系统无法开始服务器进程。请检查用户名和密码。 (Exception from HRESULT: 0x8000401A)…[通俗易懂]

    系统无法开始服务器进程。请检查用户名和密码。 (Exception from HRESULT: 0x8000401A)…[通俗易懂]开始-运行-cmd,输入aspnet_regiis.exe-i重新注册iis或者出现以下错误:检索COM类工厂中CLSID为{000209FF-0000-0000-C000-000000000046}的组件失败,原因是出现以下错误:8000401a因为配置标识不正确,系统无法开始服务器进程。请检查用户名和密码。(异常来自HRESULT:0x8000401A)。解决方案:1….

    2022年8月20日
    19
  • 微机原理与接口技术课件_微型计算机原理与接口技术课后答案

    微机原理与接口技术课件_微型计算机原理与接口技术课后答案原标题:微机原理与接口技术课程教与学(教学大纲)《微机原理与接口技术》教学大纲文/牟琦英文名称:MicrocomputerPrincipleandInterfaceTechnology适用专业:计算机类专业、自动化类专业、电子信息类专业教材:牟琦.微机原理与接口技术(第3版).[M].北京:清华大学出版社,2018一、课程的性质“微机原理与接口技术”是计算机类、电子信息类、自动化类等相关专业…

    2022年10月2日
    3

发表回复

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

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