Home Java javaTutorial Alibaba's tutorial guide for sending text messages

Alibaba's tutorial guide for sending text messages

Jul 22, 2017 pm 02:05 PM
send more than the Short message

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);
    }*/}
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set up text message blocking on iPhone How to set up text message blocking on iPhone Feb 24, 2024 pm 01:48 PM

With the popularity of smart phones, we receive a large number of text messages every day, some of which are advertising and promotional messages, and some of which are spam text messages. These text messages not only waste our time, but also occupy the space of our mobile phones. Fortunately, however, iPhones offer some features to block these annoying text messages. This article will introduce how to block text messages using iPhone. To block text messages, first open the Settings app, then scroll and tap Messages. In the information settings interface, you can see some options, including "Blocked

WhatsApp Tips: How to Send HD Photos and Videos WhatsApp Tips: How to Send HD Photos and Videos Sep 10, 2023 am 10:13 AM

WhatsApp has launched a new option that allows users to send photos and videos in high resolution through the messaging platform. Read on to find out how it's done. WhatsApp has released an update that allows iPhone and Android users to send photos and videos in high resolution, finally addressing the service's low-quality media sharing limitations. The option is called "HD Quality" and means users can send clearer photos and videos with minimal compression. For example, images captured on the iPhone can now be sent at 3024x4032 resolution instead of the previous maximum of 920x1280, while videos can be sent at 1280×718 resolution instead of 848×476.

How to send files to others on TikTok? How to delete files sent to others? How to send files to others on TikTok? How to delete files sent to others? Mar 22, 2024 am 08:30 AM

On Douyin, users can not only share their life details and talents, but also interact with other users. In this process, sometimes we need to send files to other users, such as pictures, videos, etc. So, how to send files to others on Douyin? 1. How to send files to others on Douyin? 1. Open Douyin and enter the chat interface where you want to send files. 2. Click the "+" sign in the chat interface and select "File". 3. In the file options, you can choose to send pictures, videos, audio and other files. After selecting the file you want to send, click "Send". 4. Wait for the other party to accept your file. Once the other party accepts it, the file will be transferred successfully. 2. How to delete files sent to others on Douyin? 1. Open Douyin and enter the text you sent.

How to adjust the text size in text messages How to adjust the text size in text messages Aug 29, 2023 am 11:38 AM

How to adjust the font size in text messages: 1. On the iOS device, open the "Settings" application, then select the "Display & Brightness" option, find the "Text Size" slider, and slide the slider to adjust the size of the text on the entire device. The text size, including the text in the text message; 2. On the Android device, open the "Settings" application and select the "Display" option, find the "Font Size" option, and select different font sizes to preview and adjust the text in the text message. font size.

How to get HTML form data as text and send to html2pdf? How to get HTML form data as text and send to html2pdf? Sep 06, 2023 pm 12:21 PM

html2pdf is a JavaScript package that allows developers to convert html to canvas, pdf, images, and more. It takes html as parameter and adds it to pdf or desired document. Additionally, it allows users to download the document after adding html content. Here we will access the form and add it to the pdf using the html2pdfnpm package. We will see different examples to add form data to pdf. Syntax User can follow the following syntax to pass html form data as text and send it to html2pdf. varelement=document.getElementById('form');html2

How to use check-ins with home, different locations, and timers How to use check-ins with home, different locations, and timers Mar 24, 2024 am 09:31 AM

How to let others know that you have arrived at your destination. Telling others that you have arrived at your destination safely is the most common way of "checking in" and it is easy to operate. Here are the steps to set up before you’re ready to embark on the next leg of your journey. Open a message and start a conversation with the person you want to send a check-in to. Click the plus (+) icon next to the message field. Click Check-in. Click Edit at the bottom of the prompt. Enter the destination you want to go to. Select "Done" in the upper right corner and send "Check-in." "When entering your destination, you can choose different modes of travel depending on your needs, whether that's by car, public transport or walking. Make sure you choose the device you're using correctly so your device can accurately estimate how long it will take to get to your destination. This allows you to better plan your trip and get you to your destination more conveniently.

How to block text messages on iPhone How to block text messages on iPhone Jul 31, 2023 pm 09:49 PM

How to block text messages from someone on iPhone? If you receive a text message from someone you want to block, you need to open the message on your iPhone. Once you've opened the message, click on the icon at the top with the mobile number or sender's name below it. Now click on Messages on the right side of the screen; now you will see another screen with the option to block this caller. Click this button and select Block Contact. The phone number will no longer be able to send you text messages; it will also be blocked from calling your iPhone. How to unblock blocked contacts on iPhone? If you decide to allow a blocked person to send you messages, you can unblock them on your iPhone at any time. To unblock contacts on iPhone, you need to

PHP email parsing and sending functions: email parsing and sending skills for imap_open, imap_search, mail and other functions PHP email parsing and sending functions: email parsing and sending skills for imap_open, imap_search, mail and other functions Nov 18, 2023 pm 12:23 PM

In-depth explanation of PHP email parsing and sending functions: Email parsing and sending skills of imap_open, imap_search, mail and other functions, which require specific code examples. Introduction: With the popularity of email, using PHP to parse and send emails has become a common requirement in network development. . This article will introduce in detail several commonly used email parsing and sending functions in PHP: imap_open, imap_search and mail. By understanding the usage techniques and specific code examples of these functions, readers can

See all articles