Alibaba's tutorial guide for sending text messages
Alibaba sends text messages:
Preparation work:
(1) Application management——> Application list——> Create an application to obtain the APP Key and APP Secret
(2) Obtain the SMS signature and SMS template
The SMS template after the preparation is completed
After the preparation work is completed, implement it in the program:
import com.taobao.api.DefaultTaobaoClient;import com.taobao.api.TaobaoClient;import com.taobao.api.request.AlibabaAliqinFcFlowChargeProvinceRequest;import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;public class ceshi {public static void main(String[] args) {// TODO Auto-generated method stub/*//官网的url,http请求,正式环境地址 String url = ""; //Top分配给应用的APPKey String appkey = "23859907"; //Top分配给应用的密匙 String secret = "3249c3b6a29aee38a6c9c63a9093a314"; TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret); //实例化请求 AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest(); //公共会穿参数,在“消息返回”中会透传回改参数 req.setExtend("123456"); //(必写)短信类型,传入值填写normal req.setSmsType("normal"); //(必写)短信签名,传入的短信签名必须是在阿里大鱼“管理中心-短信签名管理”中可用的签名 req.setSmsFreeSignName("羽品测试"); //短信模板变量,传参规则{"key","value"} // req.setSmsParamString("自己的变量"); //(必写)短信接收号码,支持单个或多个手机号码,多个手机号码间用英文逗号隔开 req.setRecNum("15387108387"); //短信模板ID,使用的模板必须在阿里大于“管理中心-短信模板管理”中的可用模板 req.setSmsTemplateCode("自己的模板ID"); //实例化响应 AlibabaAliqinFcSmsNumSendResponse res = new AlibabaAliqinFcSmsNumSendResponse(); System.out.println(res.getBody());*//** * 短信验证码 *///1.获取手机号、输入的验证码//2.生成随机验证码//3.调用短信接口,发送验证码短信//4.比较页面传过来的验证码与随机生成的验证码是否相等 // 官网的URL String rusult = null;// 官网的URLString url = "http://gw.api.taobao.com/router/rest";// 成为开发者,创建应用后系统自动生成String appkey = "23859907"; String secret = "3249c3b6a29aee38a6c9c63a9093a314"; String number = "520"; TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret); AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest(); req.setExtend("123456"); req.setSmsType("normal"); req.setSmsFreeSignName("羽品测试"); req.setSmsParamString("{\"number\":\"1234\"}"); req.setRecNum("15387108387"); req.setSmsTemplateCode("SMS_67785100");try { AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req); System.out.println(rsp.getBody()); rusult = rsp.getSubMsg(); } catch (Exception e) { e.printStackTrace(); } System.out.println(rusult); } /* * 通知短信 */// 官网的URL /*String rusult = null; // 官网的URL String url = ""; // 成为开发者,创建应用后系统自动生成 String appkey = "23859907"; String secret = "3249c3b6a29aee38a6c9c63a9093a314"; TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret); AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest(); req.setExtend("1234"); req.setSmsType("normal"); req.setSmsFreeSignName("羽品测试"); req.setRecNum("15387108387"); req.setSmsTemplateCode("SMS_69005127"); try { AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req); System.out.println(rsp.getBody()); rusult = rsp.getSubMsg(); } catch (Exception e) { e.printStackTrace(); } System.out.println(rusult); }*/}
The jar packages to be imported are:
The above is the detailed content of Alibaba's tutorial guide for sending text messages. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.