短信验证码/通知 - 代码示例 * * * * * [[PHP](smscode/PHP.md)][[JAVA](smscode/JAVA.md)][[ASP](smscode/ASP.md) [[ASP.NET(C#)](smscode/ASPNET.md)][[JSP](smscode/JSP.md)][[C](smscode/C.md)][[C++](smscode/C++.md)][[GO](smscode/GO.md)][[NODE.JS](smscode/NODEJS.md)][[PYTHON](smscode/PYTHON.md)][[RUBY](smscode/RUBY.md)][[VB6](smscode/VB6.md)] PYTHON代码示例 ~~~ # 接口类型:企讯云短信接口,支持发送验证码短信、订单通知短信等。 # 接口地址:http://service.qixunpush.com/sendSMS # 账户注册:请联系客服开通账户 # 注意事项: #(1)调试期间,请使用用系统默认的短信内容:您的验证码是:【变量】。请不要把验证码泄露给其他人。 #(2)请使用 account 及 password 来调用接口,可联系客服获取; #(3)该代码仅供接入企讯云短信接口参考使用,客户可根据实际需要自行编写; # 代码在python3,安装httplib和urllib库下测试通过2018-07-13 import http.client import urllib host = "service.qixunpush.com" sms_send_uri = "/sendSMS" #用户名 和 密码 请联系客服获取 account = "用户名" password = "密码" def send_sms(text, mobile): params = urllib.parse.urlencode({'account': account, 'password' : password, 'subject': text, 'phonelist':mobile }) 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() print(params) conn.close() return response_str if __name__ == '__main__': mobile = "139xxxxxxxx" text = "您的验证码是:123456。请不要把验证码泄露给其他人。【企讯】" print(send_sms(text, mobile)) ~~~