短信营销 - 代码示例 * * * * * [[PHP](sms/PHP.md)][[JAVA](sms/JAVA.md)][[ASP](sms/ASP.md) [[ASP.NET(C#)](sms/ASPNET.md)][[JSP](sms/JSP.md)][[C](sms/C.md)][[C++](sms/C++.md)][[GO](sms/GO.md)][[PYTHON](sms/PYTHON.md)][[VB6](sms/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" #多个号码用半角逗号分隔(get请求不能超过100个号码)# text = "明天上午11点请着正装参加会议【企讯】" print(send_sms(text, mobile)) ~~~