中秋节,作为中国传统节日之一,不仅是家人团聚的时刻,也是商家提高销售业绩的黄金时期。在这个充满温情与消费氛围的节日里,合理利用短信平台进行精准营销,可以显著提高企业的销售业绩。
支持免费对接试用乐讯通PaaS平台 找好用的短信平台,选择乐讯通,短信群发|短信平台|群发短信软件|群发短信平台|乐讯通PaaS平台http://yun.loktong.com/login/register/0c61bafb77
#彩信短信发送DEMO
import urllib.request
import urllib
import json
import hashlib
import time
import base64
#参数配置
url = "http://www.lokapi.cn/smsUTF8.aspx"
rece = "xml"
username = "******"
password = "******"
token = "******"
mobile = "177123456"
content = "祝你生日快乐"
title="祝福短信"
def MD5(str):
m = hashlib.md5()
m.update(str.encode(encoding='UTF-8'))
return m.hexdigest().upper()
#密码加密
passwd = MD5(password)
#时间戳
ticks = int(time.time() * 1000)
#构造发送主体
dict = {"action": "sendimagetext", "username": username,
"password": passwd, "token": token, "timestamp": ticks}
body = "action=sendimagetext&username={username}&password={password}&token={token}×tamp={timestamp}".format(username=username, password=passwd, token=token, timestamp=ticks
)
sign = MD5(body)
dict["sign"] = sign
dict["rece"] = rece
dict["title"] = title
dict["mobile"] = mobile
#文字
engb = content.encode(encoding='GB2312')
txt = base64.b64encode(engb)
#图片
extension = "jpg"
base64_data=""
with open("D:\\我的文档\\Pictures\\th.jpg", "rb") as f:
base64_data = base64.b64encode(f.read())
message = "txt|{txt},{ext}|{base_data};".format(txt=txt, ext=extension,base_data=base64_data)
message = message.replace("%", "%25")
message = message.replace("&", "%26")
message = message.replace("+", "%2B")
dict["message"] = message
headers = {
'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
}
data = urllib.parse.urlencode(dict).encode('utf-8')
request = urllib.request.Request(url, data, headers)
text_rece = urllib.request.urlopen(request).read().decode('utf-8')
print("彩信短信接收数据:" + text_rece)