#!/usr/local/bin/python
#-
-Coding:utf-8--
author:jackytime:14-2-22 pm 11:48desc: Python code invocation example for SMS HTTP interface
Import Httplib
Import Urllib
Import JSON
#服务地址
Host = "Intapi.253.com"
#端口号
Port = 80
#版本号
Version = "v1.1"
#查账户信息的URI
Balance_get_uri = "/balance/json"
#智能匹配模版短信接口的URI
Sms_send_uri = "/send/json"
#创蓝账号
account = ""
#创蓝密码
Password = ""
Def get_user_balance ():
"""
Take account balance
"""
params = {' account ': Account, ' Password ': password}
Params=json.dumps (params)
headers = {"Content-type": "application/json"}conn = httplib.HTTPConnection(host, port=port)conn.request(‘POST‘, balance_get_uri, params, headers)response = conn.getresponse()response_str = response.read()conn.close()return response_str
def send_sms (text, phone):
"""
can send text messages with the interface
"""
If name = = 'main':
#手机号码, Format (area code + mobile number), for example: 8615800000000, where 86 is China's area code
Phone = "8615800000000"
Text = "253 Cloud Communication" Your verification code is 1234 "
#查账户余额print(get_user_balance())#调用智能匹配模版接口发短信print(send_sms(text, phone))
Ruby
Note: The following code is only for the convenience of customer testing and provide the sample code, the customer can according to their own needs to write the code for Learning and research interface only for use, but provides a reference
Require ' net/http '
Require ' URI '
Require ' JSON '
params = {
"Account" = "",
"Password" = "a.123456",
Mobile phone number, format (area code + mobile number), for example: 8615800000000, of which 86 is China's area code
"mobile" => "8615800000000",
}.to_json
def send_data (Url,data)
url = uri.parse (URL)
req = net::http::P ost.new (url.path,{' content-type ' = ' Application/json '})
Req.body = Data
res = net::http.new (url.host,url.port). start{|http| http.request (req)}
puts res.body
End
Send_data (' Http://intapi.253.com/send/json ', params)
"PYTHON" Blue 253 Cloud communication platform International SMS API interface Demo