preparation

  • According to carrier requirements, this interface is available only to enterprise users with real name authentication. Therefore, ensure that you are enterprise users with real name authentication before using this interface

  • To apply for an interface, you can see the call credentialrequest key for this interface in the personal center ➡️ data center ➡️ my API module

  • Interface application access: www.juhe.cn/docs/api/id…

  • Number of requests to purchase data (free and complimentary interfaces can be debugged first)

  • You must apply for the SMS template in advance in the personal center on the aggregation official website, and only after the reception service is approved can you invoke the interface

Special instructions

  • Please carefully read the interface documentation on the official website, which is the agreement between aggregation data and developers. It will help you understand the interface business, so as to carry out the development work smoothly

  • The focus of this example is to help the developer get the response data from the interface. The business logic of data processing for the developer will not be discussed in this article

  • This example is designed to simplify the calling steps of developers as much as possible. It does not encapsulate functional modules as independent utility classes, which is convenient for developers to run debugging directly after one-click copy

  • Due to the limitations of horizontal ability, there are inevitable mistakes and omissions in the example, if found, please criticize and correct

Interface note

  • The carrier can receive only one packet with one number and one signature within one minute, three packets within 10 minutes, four packets within one hour, and 20 packets a day. Otherwise, the packet may be blocked by the carrier

  • The SMS API itself does not limit the sending frequency. Users need to set the specific sending frequency, which is limited to the domestic mobile phone number

  • Please be sure to add image verification code and other anti-malicious attack mechanism, in case of SMS bombing, marketing content finally add back T unsubscribe, marketing SMS send time: 8:30 to 21:30. Marketing content has anti-phishing mechanism, do not send a single, mobile 20 (circular call), Unicom telecom does not limit

  • One SMS message (including signature) contains 70 characters or less. Messages exceeding 70 characters are charged for each 67 characters

Parameters that

Parameter names mandatory instructions
mobile true Mobile phone no.
tpl_id true Template id
key true Request key for the application
tpl_value false Template variables, depending on the variables in the template, can be null

Node.js invokes the request code

// Node request module installation command: NPM install request

var request = require('request');
var querystring = require('querystring');

var queryData = querystring.stringify({
    "mobile": "180xxxxxxxx".// Mobile phone number of the user who receives SMS messages
    "tpl_id": "xxx".// ID of the SMS template you have applied for. The value can be changed based on site requirements
    "tpl_value": "#code#=1235231".// You set the template variable, modify according to the actual situation; Null if there is no variable
    "key": "The ApiKey you applied for".// Apply APPKEY(apply detail page query)
});

var queryUrl = 'http://v.juhe.cn/sms/send';


request.post({url:queryUrl, form:queryData},function (error, response, body) {
    if(! error && response.statusCode ==200) {
        var jsonObj = JSON.parse(body); // Parse the JSON content returned by the interface
        if (jsonObj) {
            var errorCode = jsonObj.error_code;
            var reason = jsonObj.reason;
            if (errorCode == 0) {
                // The request is sent successfully. You can modify the request based on the actual logic
                var sid = jsonObj.result.sid;
                
                console.log("Sent successfully: SMS ID:"+sid);
            } else {
                // The request failed
                console.log('Request failed:'+errorCode+' '+reason); }}else{
            // The request fails due to network exceptions. You can modify the request based on the actual logic
            console.log('Parse JSON exception'); }}else {
        // The request fails due to network exceptions. You can modify the request based on the actual logic
        console.log('Request exception'+error+response.statusCode); }})Copy the code

This article is from: SDK community (sdK.cn) is a neutral community where there is a variety of front-end knowledge, a wealth of apis, ai developers who love to learn, funny developers who can teach you Python, and the future of the hot cloud. When all the elements are put together, Let’s create a professional, fun and valuable developer community with rich imagination to help developers realize their own value!