python 实现微信模板消息发送

python 实现微信模板消息发送,第1张

概述python 实现微信模板消息发送

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

#WechatPush.py# enCoding: utf-8import urllib2,Jsonclass WechatPush(object):	def __init__(self,appID,secrect):		self.appID = appID		self.secrect = secrect#获取accesstoken	def getToken(self):		#判断缓存		url = 'https://API.weixin.qq.com/cgi-bin/token?grant_type=clIEnt_credential&appID='+self.appID + "&secret="+self.secrect		f = urllib2.urlopen(url)		s = f.read()		#读取Json数据		j = Json.loads(s)		j.keys()		token = j['access_token']		return token#开始推送	def do_push(self,touser,template_ID,url,data,topcolor):		if topcolor.strip()=='':			topcolor = "#7B68EE"		dict_arr = {'touser': touser,'template_ID':template_ID,'url':url,'topcolor':topcolor,'data':data}		Json_template = Json.dumps(dict_arr)		token = self.getToken()		requst_url = "https://API.weixin.qq.com/cgi-bin/message/template/send?access_token="+token		content = self.post_data(requst_url,Json_template)		#读取Json数据		j = Json.loads(content)		j.keys()		errcode = j['errcode']		errmsg = j['errmsg']		return errmsg#模拟post请求	def post_data(self,para_dct):		para_data = para_dct		f = urllib2.urlopen(url,para_data)		content = f.read()		return content

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的python 实现微信模板消息发送全部内容,希望文章能够帮你解决python 实现微信模板消息发送所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1198722.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存