Sending Single SMS with Specific Template


HTTP Header:


Accept: application/json;charset=utf-8;
Content-Type:application/x-www-form-urlencoded;charset=utf-8;


URL: https://sms.yunpian.com/v2/sms/tpl_single_send.json


Request:


Method: POST


Request Parameter:

PARAMETER

TYPE

REQUIRED

DESCRIPTION

EXAMPLE

apikey

string

Yes

APIKEY is credentials you can find on the "Account Dashboard page". It is the string of 32-bit characters.

9b11127a9701975c
734b8aee81ee3526

mobile

string

Yes

The destination phone number

13812341234

tpl_id

long

Yes

The template id

100

tpl_value

string

No

It is the key-value pair. Please encode the variable name and variable value with urlencode first, and pass it.
Please refer to the code demo

.
p.s.If the variable is existed in the template, both variable key and variable name can not be null. If there is no variable in the template, please assign tpl_value="".

Template: 【Yunpian】Your verification code is 12345.
Final result: 【Yunpian】Your verification code is 12345. tplvalue=urlencode("#code#") + "=" + urlencode("1234") + "&" + urlencode("#company#") + "=" + urlencode("Yunpian");
If you want to send the request directly, please use the below format: tplvalue=urlencode(urlencode("#code#") + "=" + urlencode("1234") + "&" + urlencode("#company#") + "=" + urlencode("Yunpian"));

extend

string

No

Extend number. Contact us if necessary.

001

uid

string

No

The ID defined by user. It is a string, and up to 256 bit.

10001


java Request examples


/**Sending Single SMS with Specific Template

* @param apikey

* @param mobile

* @param tpl_id

* @param tpl_value

* @return json

*/

public static String tplSingleSend(String apikey, String mobile, long tpl_id) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("apikey", apikey);
    params.put("mobile", mobile);
    params.put("tpl_id", String.valueOf(tpl_id));
    params.put("tpl_value",URLEncoder.encode("#code#", ENCODING) + "=" + URLEncoder.encode("1234", ENCODING) + "&" + URLEncoder.encode("#min#", ENCODING) + "=" + URLEncoder.encode("5",ENCODING));
    return post("https://sms.yunpian.com/v2/sms/tpl_single_send.json", params);
}


php Request examples


/** Sending Single SMS with Specific Template

* @param apikey

* @param mobile

* @param tpl_id

* @param tpl_value

* @return json

*/

public function tplSingleSend( $apikey , $mobile , $tplId) {

        $param = [
                'apikey' => $apikey,
                'mobile' => $mobile,
                'tpl_id' => $tplId,
                'tpl_value' =>('#time#').'=2018-10-11 12:10:11'.'&'.('#content#').'='.urldecode('A 30% bonus this year')
                ];

    return post("https://sms.yunpian.com/v2/sms/tpl_single_send.json", params);
}


SDK Download

We provide SDKs to allow you to access with Yunpian APIs quickly according to your languages.

Response:

JSON Representations:

{
  "code": 0,
  "msg": "发送成功",
  "count": 1,
  "fee": 1,
  "unit": "RMB",
  "mobile": 13012312312,
  "sid": 1097
}


Response Parameter:

PARAMETER

TYPE

REQUIRED

DESCRIPTION

code

integer

The status code of the SMS. SMS delivery information is reflected in message status. The possible values can be found in the"Return Code Description".

0

msg

string

Detailed status of SMS. SMS delivery information is reflected in message status. The possible values can be found in the"Return Code Description".

"发送成功"

count

integer

SMS count

1

fee

double

Deduction Amount. One SMS can support 70 words. If the words is more than 70 words, will separate it per 67 words .

0.05

unit

string

Unit

"RMB"

mobile

string

Report status

"13200000000"

sid

long(64 bit)

SMS id