1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 调用API发送短信python

调用API发送短信python

时间:2024-06-20 09:14:50

相关推荐

调用API发送短信python

import http.clientimport urllibhost = ""sms_send_uri = "/webservice/sms.php?method=Submit"# 用户名是登录用户中心->验证码短信->产品总览->APIIDaccount = "xxxxxxxx"# 密码 查看密码请登录用户中心->验证码短信->产品总览->APIKEYpassword = "xxxxxxxxxxxxxxxxxxxxxx"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_strif __name__ == '__main__':mobile = "1833xxxxxxxx"text = "您的验证码是:987654。请不要把验证码泄露给其他人。"print(send_sms(text, mobile))

需要再互意无线注册账号会送免费的二十条短信包

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。