#接口類型:互億無線語音通知接口。
#賬戶注冊:請通過該地址開通賬戶https://user.ihuyi.com/new/register.html
#注意事項:
#(1)調(diào)試期間,請仔細閱讀接口文檔;
#(2)請使用APIID(查看APIID請登錄用戶中心->語音通知->帳戶及簽名設置->APIID)及 APIkey來調(diào)用接口
#(3)該代碼僅供接入互億無線語音通知接口參考使用,客戶可根據(jù)實際需要自行編寫;
#!/usr/local/bin/python
#-*- coding:utf-8 -*-
import httplib
import urllib
host = "api.vm.ihuyi.com"
sms_send_uri = "/webservice/voice.php?method=Submit"
#//用戶名是登錄用戶中心->語音通知->帳戶及簽名設置->APIID
account = "用戶名"
#密碼 查看密碼請登錄用戶中心->語音通知->帳戶及簽名設置->APIKEY
password = "密碼"
def send_sms(text, mobile):
params = urllib.urlencode({'account': account, 'password' : password, 'content': text, 'mobile':mobile,'format':'json' })
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPConnection(host, port=80, timeout=30)
conn.request("POST", sms_send_uri, params, headers)
response = conn.getresponse()
response_str = response.read()
conn.close()
return response_str
if __name__ == '__main__':
mobile = "138xxxxxxxx"
text = "您的訂單號是:0648。已由順風快遞發(fā)出,請注意查收。"
print(send_sms(text, mobile))
驗證碼已發(fā)送到您的手機,請查收!
輸入驗證碼后,點擊“開通體驗賬戶”按鈕可立即開通體驗賬戶。