# python使用互譯無線發送手機短信
# 接口類型:互億無線觸發短信接口,支持發送驗證碼短信、訂單通知短信等。
# 賬戶注冊:請通過該地址開通賬戶http://sms.ihuyi.com/register.html
# 注意事項:
# (1)調試期間,請用默認的模板進行測試,默認模板詳見接口文檔;
# (2)請使用APIID(查看APIID請登錄用戶中心->驗證碼短信->產品總覽->APIID)及 APIkey來調用接口;
# (3)該代碼僅供接入互億無線短信接口參考使用,客戶可根據實際需要自行編寫;
# !/usr/local/bin/python
# -*- coding:utf-8 -*-
import http.client
import urllib
host = "106.ihuyi.com"
sms_send_uri = "/webservice/sms.php?method=Submit"
# 用戶名是登錄用戶中心->驗證碼短信->產品總覽->APIID
account = "C58023834"
# 密碼 查看密碼請登錄用戶中心->驗證碼短信->產品總覽->APIKEY
password = "32dc4c13668beeb673ba91202d61405d"
def send_sms(text, mobile):
params = urllib.parse.urlencode(
{'account': account, 'password': password, 'content': text, 'mobile': mobile, 'format': 'json'})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = http.client.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 = "15999999999"
text = "您的驗證碼是:123456。請不要把驗證碼泄露給其他人。"
print(send_sms(text, mobile))
account和password在這個位置的,找不到對比圖片位置。
