python3 调用手机短信
手机注册:http://sms.ihuyi.com/new/login.html#!/usr/local/bin/python# -*- coding:utf-8 -*-from http import clientfrom urllib.parse import urlencodehost = "106.ihuyi.com"sms_send_uri = "/webservice/sms.php?
·
手机注册: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))
更多推荐
已为社区贡献1条内容
所有评论(0)