Sending Single SMS


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/single_send.json


Send Limit


You can send as many messages as you like. However, Yunpian have some rules for harassment prevention.


Harassment Prevention:


No more than one message every 30 seconds and no more than three messages every five minutes to the same destination number with the same message body. Contact with customer service team if you have special needs.


Request:


Method: POST


Request Parameter:

PARAMETERTYPEREQUIREDDESCRIPTIONEXAMPLE
apikeystringYesAPIKEY is credentials you can find on the "Account Dashboard" page. It is the string of 32-bit characters.9b11127a9701975c
734b8aee81ee3526
mobilestringYesThe destination phone, we only support single send. International SMS:The international mobile number must contain the country code. Format with a "+" and country code. Please encode"+"with urlencode.15205201314 or urlencode("+93701234567")
textstringYesThe text of the message you want to send, limited to 500 words. It should be audited by our customer service team first.【Yunpian】Your Verify Code is 12345.
extendstringNoSMS extend Number. Please contact with our customer service team if necessary.001
uidstringNoThe SMS ID in your application. It is created by yourself.10001
callback_urlstringNoAfter SMS sending, the status report will be pushed to this address (the status is returned by carrier). If the push address is fixed, it is recommended to make the batch setting in "Data Push and Get". If address has been set in the "Data Push and Get" and the HTTP requests also contains this parameter, it will be based on the URL in the HTTP requests.http://yourreceiveurl_address
registerbooleanNoIf pass"true", it will be considered as the verification code SMS which is used for registration. This data will be included in the statistic registration success rate. Please contact with customer service team if necessary.true
mobile_statbooleanNoStatic who click the url.true


Parameter Description:


mobile_stat


If you want to know who click the Yunpian’s short url, please follow the below steps:


  1. Please generate Yunpian’s short url. You can refer to Get Short Link Statistics.
  1. Use ‘Sending SMS’ or ’Sending Batch SMS’ API to send the SMS. Please pass ’true’ for this parameter. We will customize the short url for each SMS. It means the short url are different for each SMS.
  1. You can find the specific statistics in the Yunpian backend.


java Request examples


/*
* Sending SMS
* @param apikey
* @param text
* @param mobile
* @return json
*/

public static String singleSend(String apikey, String text, String mobile) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("apikey", apikey);
    params.put("text", text);
    params.put("mobile", mobile);
    return post("https://sms.yunpian.com/v2/sms/single_send.json", params);
}


php Request examples


/**Sending SMS

* @param apikey

* @param text

* @param mobile

* @return json

*/

public function singleSend($apikey, $text, $mobile) {
        $param = [
                'apikey' => $apikey,
                'mobile' => $mobile,
                'text' => $text,
                ];
    return post("https://sms.yunpian.com/v2/sms/single_send.json", params);
}


cURL Request examples


#Sending SMS

# @param apikey

# @param text

# @param mobile

# @return json

curl -X "POST" "https://sms.yunpian.com/v2/sms/single_send.json" \
  -H "content-type: application/x-www-form-urlencoded" \
  -d "apikey=4d6cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -d "mobile=158xxxxxxxx" \
  -d "text=【云片网】您的验证码是1234"


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": 0.05,
  "unit": "RMB",
  "mobile": "13012312312",
  "sid": 16741236146
}


Response Parameter:

PARAMETERTYPEDESCRIPIONEXAMPLE
codeintegerThe 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
msgstringThe detailed status of the SMS. SMS delivery information is reflected in message status. The possible values can be found in the" Return Code Description"."发送成功"
countintegerSMS count1
feedoubleDeduction Amount. One SMS can support 70 words. If the SMS is more than 70 words, will separate it per 67 words .0.05
unitstringUnit"RMB"
mobilestringMobile number"13200000000"
sidlong(64 bit)SMS id16741236146