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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

阿里短信单发,批量发送_如何用阿里小号发短信(阿里巴巴拟在新加坡建设全球总部)

發(fā)布時(shí)間:2023/12/15 综合教程 27 生活家
生活随笔 收集整理的這篇文章主要介紹了 阿里短信单发,批量发送_如何用阿里小号发短信(阿里巴巴拟在新加坡建设全球总部) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.導(dǎo)入

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

Jetbrains全家桶1年46,售后保障穩(wěn)定

單條發(fā)送

	/**
	 * 阿里云短信發(fā)送
	 */
	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); //接收短信的手機(jī)號(hào)碼。
		request.putQueryParameter("SignName", PropertiesUtils.getInstance().getProperty("signName"));//短信簽名名稱
		request.putQueryParameter("TemplateCode", temNo);//短信模板ID
		request.putQueryParameter("TemplateParam", content);//短信模板變量對(duì)應(yīng)的實(shí)際值,JSON格式 {"code":"1111"}

		CommonResponse response= null;
		try {
			response = client.getCommonResponse(request);
			System.out.println("短信接口返回的數(shù)據(jù)----------------");
			System.out.println(response.getData());

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

批量發(fā)送

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();
	}

總結(jié)

以上是生活随笔為你收集整理的阿里短信单发,批量发送_如何用阿里小号发短信(阿里巴巴拟在新加坡建设全球总部)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。