API Documentation

Global SMS API

All PaaSoo services are accessible using either HTTP or HTTPS. However, for security reasons, we highly recommend all our customers to use the HTTPS protocol.

Request method

HTTP GET

Request endpoint :
>https://api.paasoo.com/json

Example :
https://api.paasoo.com/json?key=API_KEY&secret=API_SECRET&from=PaaSoo&to=8615884401340&text=Hello+world

Parameters

Parameter Type Mandatory Description Example
key string Yes API Key: a unique account ID which can be found on your dashboard homepage. Please keep it safe! Abcdefgh
secret string Yes API Secret: a unique secret password which can be found on the dashboard homepage. Please keep it safe! Abc123EFG123
from string Yes Customizable sender ID, also called Originating Address (OA). We recommend to not use more than 11 characters, and to avoid special characters. PAASOOSMS
to string Yes Destination mobile phone number, in international format: country code (without “+”) followed by the local number (without the initial “0”) 81987654321 (81 is the country code for Japan, and 987654321 is a local Japan number without the initial 0)
text string Yes Message content : it must be encoded in URL format. For simple tests, you can use the following URLEncode tool http://www.url-encode-decode.com/ This+is+test+sms+from+PaaSoo

HTTP Response

Examples


Successful example : {"status":"0","messageid":"015bd4-d6dfa7-58w"}
Failed example : {"status_code":"Missing params.","status":"2"}

Parameter Description Example
messageid Message ID: unique ID for successful SMS requests 015bd4-d6dfa7-58w
status Message status 0 - Success : Successful
2 - Missing params : Missing mandatory parameter
4 - Invalid credentials : Incorrect API Key or Secret
5 - Unauthorized IP : Forbidden IP
6 - Invalid phone number : Incorrect destination number format
7 - Invalid sender id : Invalid sender ID format
8 - Message bombing detected: same message content to a same number in less than 3s
9 - Quota exceeded : Insufficient balance or credit limit
10 - Throttling error : allowed throughput exceeded
11 - System error
status_code Error description Missing params

Global voice API

If you are interested in this global voice API product, please contact the customer support or your account manager to enable it in your account.

Request method

HTTP GET


Request endpoint
https://api.paasoo.com/voice

Example
https://api.paasoo.com/voice?key=API_KEY&secret=API_SECRET&from=PaaSoo&to=8615884401340&lang=zh-cn&text=Hello+world&repeat=1

Parameters

Parameter Type Mandatory Description Example
key string Yes API Key: a unique account ID which can be found on your dashboard homepage. Please keep it safe! Abcdefgh
secret string Yes API Secret: a unique secret password which can be found on the dashboard homepage. Please keep it safe! Abc123EFG123
from string Yes Caller ID, or CLI. If you want to customize the caller ID, please contact the customer support or your account manager 85299998888
to string Yes Destination mobile phone number, in international format: country code (without “+”) followed by the local number (without the initial “0”) 81987654321 (81 is the country code for Japan, and 987654321 is a local Japan number without the initial 0)
lang string No The language in which the message needs to be read to the recipient nl-nl, de-de, en-gb, en-us, es-es, fr-fr, ru-ru, zh-cn, en-au, es-mx, es-us, fr-ca, is-is, it-it, ja-jp, ko-kr, pl-pl, pt-br, ro-ro
text string Yes Message content : it must be encoded in URL format. For simple tests, you can use the following URLEncode tool http://www.url-encode-decode.com/ The number of times the voice message will be repeated. The default value is “1”.
repeat string No The number of times the voice message will be repeated. The default value is “1”. 1

HTTP Response

Examples

Successful example:{"status":"0","messageid":"4b7368321"}
Failed example:{"status_code":"Missing params.","status":"2"}

Parameter Description
messageid Message ID: unique ID for successful voice message requests
status Message status code
0 - Success : Successful
2 - Missing params : Missing mandatory parameter
4 - Invalid credentials : Incorrect API Key or Secret
5 - Unauthorized IP : Forbidden IP
6 - Invalid phone number : Incorrect destination number format
7 - Invalid sender id : Invalid sender ID format
8 - Message bombing detected: same message content to a same number in less than 3s
9 - Quota exceeded : Insufficient balance or credit limit
10 - Throttling error : allowed throughput exceeded
11 - System error
status_code Error description

Message content parameters

Voice speed and break time can be customized
You can use ‘,’ to indicate a short pause, or to indicate a pause of specific duration. You can also use to indicate a specific speech
Parameter Type Description Example
break time Pause duration in s or ms <break time="is"> </break>
prosody rate Decrease or increase the speech speed by a specific percentage For example if you want to decrease the speech speed by 10%, then you should indicate prosody rate=”-10%25”(in URL encode format)
Please find below some examples:
1.Adding pause with ",":
Hello,your login token is 1, 8, 3, 4, 0.
2.Adding pause with "break":
hello,your login token is <break time="1s"/>1<break time="500ms"/>8 <break time="500ms"/>3<break time="500ms"/>4<break time="500ms"/>0.
3.Modify the speech speed with "prosody":
Your login token is <prosody rate="-10%25">1,8,3,4,0<prosody/>.

Phone Number Lookup API

Providing the information about the MSISDNs queried

Request method

HTTP GET

Request endpoint
https://api.paasoo.com/lookup

Example
https://api.paasoo.com/lookup?key=API_KEY&secret=API_SECRET&number=8615900000000

Parameters

Parameter Type Mandatory Description Example
key string Yes API Key: a unique account ID which can be found on your dashboard homepage. Please keep it safe! Abcdefgh
secret string Yes API Secret: a unique secret password which can be found on the dashboard homepage. Please keep it safe! Abc123EFG123
number string Yes Phone number to be verified (in international format) Phone number including the country code(without 00 or +): 8190555666

HTTP Response

HTTP response example
{
"requestId":"20008a-371837-e000",
"number":"8615900000000",
"format":1,
"errorCode":"00",
"cc":"86",
"countryIso":"CN",
"mccmnc":"46000",
"operator":"China Mobile"
}
Parameter Description
requestId The message ID
number Phone number to be verified (in international format)
format The validity of the phone number
0 - Invalid
1 - Valid
errorCode Error code
00 - Successful
01 - Insufficient balance
02 - Wrong credentials
03 - Subscriber absent
04 - Subscriber unknown
05 - Subscriber unindentified
06 - Missing parameters
07 - Blacklisted
cc Country code (for example 81 for Japan)
countryIso Country code (for example JP for Japan)
mccmnc Network code (for example 44010)
operator Network name (for example NTT DoCoMo Inc)

Message Status API

This API checks the current status of a message using the message ID

Request method

HTTP GET

Request endpoint
https://api.paasoo.com/dlr

Example
https://api.paasoo.com/dlr?key=API_KEY&secret=API_SECRET&messageid=MESSAGE_ID

Parameters

Parameter Type Mandatory Description Example
key string Yes API Key: a unique account ID which can be found on your dashboard homepage. Please keep it safe! Abcdefgh
secret string Yes API Secret: a unique secret password which can be found on the dashboard homepage. Please keep it safe! Abc123EFG123
messageid string Yes The message ID 015bd4-d6dfa7-58w

HTTP Response

[{
"type":"dlr",
"messageid":"015bd4-d6dfa7-58w",
"to":"8613527568886",
"status":0,
"drStatus":0,
"drStatuscode":"delivered",
"drErrcode":"0",
"price":0.03
"counts":1
"network":46000
}]
Parameter Description
type The data type should be "DLR"
messageid The message ID
to The destination phone number
status Message submission status code
0 - Success : Successful
2 - Missing params : Missing mandatory parameter
4 - Invalid credentials : Incorrect API Key or Secret
5 - Unauthorized IP : Forbidden IP
9 - Quota exceeded : Insufficient balance or credit limit
11 - System error
drStatus Message delivery status
0 - normal
400 - error
drStatuscode Message delivery status code
delivered - message delivered (status 0)
accepted - message accepted by the carrier
rejected - message rejected by the carrier (status 400)
failed - delivery failed (status 400)
expired - delivery expired (status 400)
deleted - the SMSC deleted the message without delivery (status 400)
unknown - Unknown error (status 400)
drErrcode Delivery error description
1 - Unknown error
2 - Phone number is unreachable
3 - Phone number is invalid or does not subscribe
4 - The message has been rejected by the subscriber
5 - The message has been rejected by the carrier
6 - Unable to deliver the message in a specified amount of time
7 - The SMSC deleted the message without delivery
99 - Other network errors
network The unique identifier of the destination network
price Unit price (per segment)
counts (Number of message segments)

Account balance API

This API checks the remaining balance of the customer account

Request method

HTTP GET

Request endpoint
https://api.paasoo.com/balance

Example
https://api.paasoo.com/balance?key=API_KEY&secret=API_SECRET

Parameters

Parameter Type Mandatory Description Example
key string Yes API Key: a unique account ID which can be found on your dashboard homepage. Please keep it safe! Abcdefgh
secret string Yes API Secret: a unique secret password which can be found on the dashboard homepage. Please keep it safe! Abc123EFG123

HTTP Response

Examples
{"balance":"9.77","currency":"EUR"}

Parameter Description
balance The remaining balance of the customer account
currency The balance currency

Callback URL for delivery receipts

Delivery receipts can be pushed to your callback URL in real time

Callback method

HTTP GET

Callback URL
you can define a callback URL for delivery receipts in the settings of your dashboard

Example
http://USER_CALLBACK_URL?type=dlr&messageid=MESSAGE_ID&to=6588888888&status=0&statuscode=delivered&errcode=1&network=52099

Parameters

Parameter Description
type The callback type. The value is “dlr”for delivery receipts
messageid Message ID
to The destination phone number
status Message delivery status
0 - normal
400 - error
statuscode Message delivery status code
delivered - message delivered (status 0)
accepted - message accepted by the carrier
rejected - message rejected by the carrier (status 400)
failed - delivery failed (status 400)
expired - delivery expired (status 400)
deleted - the SMSC deleted the message without delivery (status 400)
unknown - Unknown error (status 400)
errcode Delivery error description
1 - Unknown error
2 - Phone number is unreachable
3 - Phone number is invalid or does not subscribe
4 - The message has been rejected by the subscriber
5 - The message has been rejected by the carrier
6 - Unable to deliver the message in a specified amount of time
7 - The SMSC deleted the message without delivery
99 - Other network errors
network The unique identifier of the destination network
price Unit price (per segment)
counts (Number of message segments)
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Java code samples for the SMS http API
 * Based on Apache HttpClient 4.x
 */
public class JavaSmsApi {
    //Encoding format: UTF-8
    private static String ENCODING = "UTF-8";
    //SMS API endpoint; API_URL: API request URL
    private static String URI_GET_SEND_SMS = "API_URL/json";
    //Message status API endpoint; API_URL: API request URL
    private static String URI_GET_SEND_RECORD = "API_URL/api/dlr";
    //Account balance API endpoint; API_URL: API request URL
    private static String URI_GET_USER_BALANCE = "API_URL/api/balance";
    //Phone number format API endpoint; API_URL: API request URL
    private static String URI_GET_VALID_NUMBER = "API_URL/lookup";

    public static void main(String[] args) throws Exception {
        // Parameters
        String key = "********";
        String secret = "********";
        String from = "********";
        String to = "********";
        String text = "********";;
        String messageid = "********";
	 	String countryCode = "********";
        String nationalNumber = "********";

        /**************** send a SMS *****************/
        System.out.println(JavaSmsApi.getSendSms(key, secret, from, to, text));

        /**************** check a message status *****************/
        System.out.println(JavaSmsApi.getSendRecord(key, secret, messageid));

        /**************** check the account balance *****************/
        System.out.println(JavaSmsApi.getUserBalance(key, secret));

        /**************** check the validity of a phone number *****************/
        System.out.println(JavaSmsApi.getValidNumber(key, secret, countryCode, nationalNumber));
    }

    /**
     *Send SMS
     *
     * @param key       API Key
     * @param secret    API Secret
     * @param from      SenderID
     * @param to        Destination number
     * @param text      Message content
     * @return json     Data format
     * @throws Exception
     */

    public static String getSendSms(String key, String secret, String from, String to, String text) throws Exception {
        Map<String, String> params = new HashMap<String, String>();
        params.put("key", key);
        params.put("secret", secret);
        params.put("from", from);
        params.put("to", to);
        params.put("text", text);
        return get(URI_GET_SEND_SMS, params);
    }

    /**
     * Check message status
     *
     * @param key        API Key
     * @param secret     API Secret
     * @param messageid  Message ID
     * @return
     * @throws Exception
     */
    public static String getSendRecord(String key, String secret, String messageid) throws Exception {
        Map<String, String> params = new HashMap<String, String>();
        params.put("key", key);
        params.put("secret", secret);
        params.put("messageid", messageid);
        return get(URI_GET_SEND_RECORD, params);
    }

    /**
     * Check account balance
     *
     * @param key    API Key
     * @param secret API Secret
     * @return
     * @throws Exception
     */
    public static String getUserBalance(String key, String secret) throws Exception {
        Map<String, String> params = new HashMap<String, String>();
        params.put("key", key);
        params.put("secret", secret);
        return get(URI_GET_USER_BALANCE, params);
    }

    /**
     * @param key            API Key
     * @param secret         API Secret
     * @param countryCode    Country code of the destination number
     * @param nationalNumber Local format of the destination number (without the initial 0)
     * @return
     * @throws Exception
     */
    public static String getValidNumber(String key, String secret, String countryCode, String nationalNumber) throws Exception {
        Map<String, String> params = new HashMap<String, String>();
        params.put("key", key);
        params.put("secret", secret);
        params.put("countryCode", countryCode);
        params.put("nationalNumber", nationalNumber);
        return get(URI_GET_VALID_NUMBER, params);
    }


    /**
     * GET method based on HttpClient 4.x
     *
     * @param url        URL to be submitted
     * @param paramsMap  Map
     * @return           Response
     */
    public static String get(String url, Map<String, String> paramsMap) throws Exception {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        CloseableHttpResponse response = null;
        InputStream is = null;
        try {
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            for (Map.Entry<String, String> param : paramsMap.entrySet()) {
                NameValuePair pair = new BasicNameValuePair(param.getKey(), param.getValue());
                params.add(pair);
            }
            String str = EntityUtils.toString(new UrlEncodedFormEntity(params, ENCODING));
            HttpGet httpGet = new HttpGet(url + "?" + str);
            response = httpClient.execute(httpGet);
            HttpEntity entity = response.getEntity();
            String result = EntityUtils.toString(entity);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (response != null) {
                try {
                    response.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (httpClient != null) {
                try {
                    httpClient.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}
<?php
	header("Content-Type:text/html;charset=utf-8");

	$key = "xxxxxxxxxxx";
	$secret = "xxxxxxxxxxx";
	$from = "xxxxxxxxxxx";
	$to = "xxxxxxxxxxx";
	$text = "xxxxxxxxxxx";
	$messageid = "xxxxxxxxxxx";
	$nationalNumber = "xxxxxxxxxxx";
	$countryCode = "xxxxxxxxxxx";

	$curl = curl_init();

	/* 设置验证方式 */
	curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept:text/plain;charset=utf-8', 'Content-Type:application/x-www-form-urlencoded','charset=utf-8'));

	/* 设置返回结果为流 */
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

	/* 设置超时时间 */
	curl_setopt($curl, CURLOPT_TIMEOUT, 10);

	/* 设置通信方式 */
	curl_setopt($curl, CURLOPT_GET, 1);
	curl_setopt($curl, CURLOPT_GETFIELDS);
	curl_setopt($curl, CURLOPT_HEADER, 0);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

	// 查短信发送信息调用示例
	$data = array('key'=>$key,'secret'=>$secret,'from'=>$from,'to'=>$to,'text'=>$text);
	$json_data = get_send_sms($curl,$data);
	$array = json_decode($json_data,true);
	echo '<pre>';print_r($array);

	// 查发送记录信息调用示例
	$data = array('key'=>$key,'secret'=>$secret,'messageid'=>$messageid);
	$json_data = get_send_record($curl,$data);
	$array = json_decode($json_data,true);
	echo '<pre>';print_r($array);

	// 查余额信息调用示例
	$data = array('key'=>$key,'secret'=>$secret);
	$json_data = get_user_balance($curl,$data);
	$array = json_decode($json_data,true);
	echo '<pre>';print_r($array);

	// 查余额信息调用示例
	$data = array('key'=>$key,'secret'=>$secret,'countryCode'=>$countryCode,'nationalNumber'=>$nationalNumber);
	$json_data = get_user_balance($curl,$data);
	$array = json_decode($json_data,true);
	echo '<pre>';print_r($array);

	curl_close($curl);
	/***************************************************************************************/

	// 查短信发送信息
	function get_send_sms($curl,$data){
    		curl_setopt($curl, CURLOPT_URL, 'http://api.paasoo.cn/json?’);
    		curl_setopt($curl, CURLOPT_GETFIELDS, http_build_query($data));
    		return curl_exec($ch);
	}

	// 查发送记录信息
	function get_send_record($curl,$data){
    		curl_setopt($curl, CURLOPT_URL, 'http://client.paasoo.cn/api/dlr?’);
    		curl_setopt($curl, CURLOPT_GETFIELDS, http_build_query($data));
    		return curl_exec($ch);
	}

	// 余额查询信息
	function get_user_balance($curl,$data){
    		curl_setopt($curl, CURLOPT_URL, 'http://client.paasoo.cn/api/balance?’);
    		curl_setopt($curl, CURLOPT_GETFIELDS, http_build_query($data));
    		return curl_exec($ch);
	}

	// 号码格式验证
	function get_user_balance($curl,$data){
    		curl_setopt($curl, CURLOPT_URL, 'http://client.paasoo.cn/api/validnumber?’);
    		curl_setopt($curl, CURLOPT_GETFIELDS, http_build_query($data));
    		return curl_exec($ch);
	}
?>
var http = require('http');
var qs = require('querystring');

// 参数
var key = "xxxxxxxxxxx";
var secret = "xxxxxxxxxxx";
var from = "xxxxxxxxxxx";
var to = "xxxxxxxxxxx";
var text = "xxxxxxxxxxx";
var messageid = "xxxxxxxxxxx";
var countryCode = "xxxxxxxxxxx";
var nationalNumber = "xxxxxxxxxxx";

var api_host = "api.paasoo.cn";
var client_host = "client.paasoo.cn";

// 短信发送url
var uri_get_send_sms = "/json";
// 发送记录查询url
var uri_get_send_sms_record = "/api/dlr";
// 余额查询url
var uri_get_user_balance = "/api/balance";
// 余额查询url
var uri_get_valid_number = "/api/validnumber";

// ****************************** 调用接口示例 ******************************************

// 短信发送调用示例
get_send_sms(uri_get_send_sms, key, secret, from, to, text);
// 发送记录查询调用示例
get_send_sms_record(uri_get_send_sms_record, key, secret, messageid);
// 余额查询调用示例
get_user_balance(uri_get_user_balance, key, secret);
// 号码格式验证调用示例
get_valid_number(uri_get_valid_number, key, secret, countryCode, nationalNumber);

// ****************************** 调用函数 *********************************************

function get_send_sms(uri, key, secret, from, to, text) {
    var get_data = {
    	'key': key,
	'secret': secret,
	'from': from,
	'to': to,
	'text': text,
    };
    var content = qs.stringify(get_data);
    get(uri,content,api_host);
}

function get_send_sms_record(uri, key, secret, messageid){
    var get_data = {
    	'key': key,
	'secret': secret,
	'messageid': messageid,
    };
    var content = qs.stringify(get_data);
    get(uri,content,client_host);
}

function get_user_balance(uri, key, secret){
    var get_data = {
    	'key': key,
	'secret': secret,
    };
    var content = qs.stringify(get_data);
    get(uri,content,client_host);
}

function get_valid_number(uri, key, secret, countryCode, nationalNumber){
    var get_data = {
    	'key': key,
	'secret': secret,
	'countryCode': countryCode,
	'nationalNumber': nationalNumber,
    };
    var content = qs.stringify(get_data);
    get(uri,content,client_host);
}

function get(uri,content,host){
    var options = {
        host: host,
        port: 80,
        path: uri,
        method: 'GET',
        headers: {
            'Content-Type': 'application/json'
        }
    };
    var req = http.request(options, function(res) {
               res.setEncoding('utf8');
		var resData = "";
               res.on("data",function(data){
                 resData += data;
               });
               res.on("end", function() {
                 callback(null,JSON.parse(resData));
               });
    });
}
//项目需要添加System.web引用
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace paasooSmsClient {
    class Program {
        static void Main(string[] args) {
            string key = "********";
            string secret = "********";
            string from = "********";
            string to = "********";
            string text = "********";;
            string messageid = "********";
	     string countryCode = "********";
            string nationalNumber = "********";

	    //短信发送url
      	     string uri_get_send_sms = "http://api.paasoo.cn/json";
    	    //发送记录查询url
            string uri_get_send_record = "http://client.paasoo.cn/api/dlr";
            //余额查询url
            string uri_get_user_balance = "http://client.paasoo.cn/api/balance";
    	    //号码格式验证url
            string uri_get_valid_number = "http://client.paasoo.cn/api/validnumber";

            // 参数字符串拼接
            string get_send_sms = "?key=" + key + "&secret=" + secret + "&from=" + from + "&to=" + to + "&text =" + text;
            string get_send_sms_record = "?key=" + key + "&secret=" + secret + "&messageid=" + messageid;
            string get_user_balance = "?key=" + key + "&secret=" + secret;
            string get_valid_number = "?key=" + key + "&secret=" + secret + "&countryCode =" + countryCode + "&nationalNumber =" + nationalNumber;

            // 接口调用示例
            HttpGet(uri_get_send_sms, get_send_sms);
            HttpGet(uri_get_send_record, get_send_sms_record);
            HttpGet(uri_get_user_balance, get_user_balance);
            HttpGet(uri_get_valid_number, get_valid_number);
        }

        public static void HttpGet(string url, string postDataStr) {
            byte[] dataArray = Encoding.UTF8.GetBytes(postDataStr);
            // Console.Write(Encoding.UTF8.GetString(dataArray));

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.ContentType = "application/json";
            request.ContentLength = dataArray.Length;
            //request.CookieContainer = cookie;
            Stream dataStream = request.GetRequestStream();
            dataStream.Write(dataArray, 0, dataArray.Length);
            dataStream.Close();
            try {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                String res = reader.ReadToEnd();
	         response.Close();
                reader.Close();
		 Console.Write("\nResponse Content:\n" + res + "\n");
            } catch(Exception e) {
                Console.Write(e.Message + e.ToString());
            }
        }
    }
}
import httplib
import urllib
import json

#服务地址
api_host = "api.paasoo.cn";
client_host = "client.paasoo.cn";
port = 80

// 短信发送url
uri_get_send_sms = "/json";
// 发送记录查询url
uri_get_send_sms_record = "/api/dlr";
// 余额查询url
uri_get_user_balance = "/api/balance";
// 号码格式验证url
uri_get_valid_number = "/api/validnumber";

#调用示例
def get_send_sms(key, secret, from, to, text):
    params = urllib.urlencode({'key': key, 'secret': secret, 'from': from, 'to': to, 'text': text})
    headers = {"Content-type": "application/json", "Accept": "text/plain"}
    conn = httplib.HTTPConnection(api_host, port=port, timeout=30)
    conn.request("GET", uri_get_send_sms, params, headers)
    response = conn.getresponse()
    response_str = response.read()
    conn.close()
    return response_str

def get_send_sms_record(key, secret, messageid):
    params = urllib.urlencode({'key': key, 'secret': secret, 'messageid': messageid})
    headers = {"Content-type": "application/json", "Accept": "text/plain"}
    conn = httplib.HTTPConnection(client_host, port=port, timeout=30)
    conn.request("GET", uri_get_send_sms_record, params, headers)
    response = conn.getresponse()
    response_str = response.read()
    conn.close()
    return response_str

def get_send_sms_record(key, secret):
    params = urllib.urlencode({'key': key, 'secret': secret})
    headers = {"Content-type": "application/json", "Accept": "text/plain"}
    conn = httplib.HTTPConnection(client_host, port=port, timeout=30)
    conn.request("GET", uri_get_user_balance, params, headers)
    response = conn.getresponse()
    response_str = response.read()
    conn.close()
    return response_str

def get_send_sms_record(key, secret, countryCode, nationalNumber):
    params = urllib.urlencode({'key': key, 'secret': secret, 'countryCode': countryCode, 'nationalNumber': nationalNumber})
    headers = {"Content-type": "application/json", "Accept": "text/plain"}
    conn = httplib.HTTPConnection(client_host, port=port, timeout=30)
    conn.request("GET", uri_get_valid_number, params, headers)
    response = conn.getresponse()
    response_str = response.read()
    conn.close()
    return response_str


if __name__ == '__main__':

    key = "xxxxxxxxxxx";
    secret = "xxxxxxxxxxx";
    from = "xxxxxxxxxxx";
    to = "xxxxxxxxxxx";
    text = "xxxxxxxxxxx";
    messageid = "xxxxxxxxxxx";
    countryCode = "xxxxxxxxxxx";
    nationalNumber = "xxxxxxxxxxx";

    #短信发送信息调用示例
    print get_send_sms(key, secret, from, to, text)
    #发送记录信息调用示例
    print get_send_sms_record(key, secret, messageid)
    #余额信息调用示例
    print get_send_sms_record(key, secret)
    #号码格式验证调用示例
    print get_send_sms_record(key, secret, countryCode, nationalNumber)