后台审核通过后会发送消息给前端,但是一直提示无效的url
代码:
# 发送入职
def send_newstaff_msg(self, openid, name, job, onDutyTime):
"""
:param openid: 微信公众号的openid
:param name: 姓名
:param job: 职位
:param onDutyTime: 入职时间
:return: 返回消息结果
"""
token = self.encode_token(openid, 'wechattools')
mode_id = "消息模板ID"
url = "http://weixin.szzhaowei.net/wx/weixin/hrm/Register?token=%s" % token
data = {
"first": {
"value": f"亲爱的{name},欢迎您来应聘我司{job}岗位,经公司审核,"
f"现诚意邀请您于 {onDutyTime} 日来我司办理入职手续!",
"color": "#000000"
},
"keyword1": {
"value": job,
"color": "#000000"
},
"keyword2": {
"value": name,
"color": "#000000"
},
"keyword3": {
"value": "待入职",
"color": "#000000"
},
"keyword4": {
"value": onDutyTime,
"color": "#000000"
},
"remark": {
"value": f"为节约您办理入职的时间,请点击页面提前完善您的应聘履历信息",
"color": "#173177"
}
}
ret, msg = self.send_msg(openid, mode_id, url, data)
if not ret:
self.log.error("send_wechat_msg", "发送微信公众号信息错误, 原因: %s" % msg)
return False, msg
return True, "成功"
# 发送消息
def send_msg(self, openid, template_id, url, data):
ret, access_token = self.get_access_token()
if not ret:
return False, access_token
the_url = 'http://weixin.szzhaowei.net/cgi-bin/message/template/send?access_token=%s' % access_token
the_data = {
"touser": openid,
"template_id": template_id,
"url": url,
"data": data
}
self.log.error("wechat_send_msg", "发送消息内容: %s" % json.dumps(the_data))
msgret = requests.post(the_url, data=json.dumps(the_data)).json()
if str(msgret["errcode"]) != '0':
self.log.error("wechat_send_msg", "错误编码:%s" % str(msgret["errcode"]))
return False, msgret["errmsg"]
return True, msgret["msgid"]
这是什么鬼?你自己的推送服务器?用微信的模板?