手机注册:http://sms.ihuyi.com/new/login.html

#!/usr/local/bin/python
# -*- coding:utf-8 -*-
from http import client
from urllib.parse import urlencode

host = "106.ihuyi.com"
sms_send_uri = "/webservice/sms.php?method=Submit"
account = "用户名"
password = "密码"
def send_sms(text, mobile):
    params = urlencode(
        {'account': account, 'password': password, 'content': text, 'mobile': mobile, 'format': 'json'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = 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 = "187********"
    text = "您的验证码是:121254。请不要把验证码泄露给其他人。"
    print(send_sms(text, mobile))
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐