当前位置: 首页 > news >正文

商城小程序模板windows优化大师是什么

商城小程序模板,windows优化大师是什么,房子装修设计app,阿里云 个人网站备案1、根据appid,secret获取token 2、查找粉丝 3、指定模板及粉丝id发送模板消息 4、链接SqlServer数据库获取消息任务 5、创建定时任务监听消息 from logging import exception import time import pymysql import datetime; from utils.http_utils import *; from model.msg_wx_…

1、根据appid,secret获取token

2、查找粉丝

3、指定模板及粉丝id发送模板消息

4、链接SqlServer数据库获取消息任务

5、创建定时任务监听消息

from logging import exception
import time
import pymysql
import datetime;
from utils.http_utils import *;
from model.msg_wx_model import *;
from threading import Timerappid = "wx*****";
appsecret = "****";   
template_id = '9uWUl0evW9o5Q5KPbZaa4WxpXOsHN9V28vWPG2T**'     #模板id
token = "";#查找公众号所有的粉丝
def findUser():url = f"https://api.weixin.qq.com/cgi-bin/user/get?access_token={token}&next_openid=";result = httpGet(url,"");print(result);for row in result["data"]["openid"]:print(row);url =  "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + token + "&openid=" + row;jsonText = httpGet(url,"");print(jsonText);pass;#指定粉丝发送模板消息
def send(userId, content):list = content.split('|');first = list[0]k1=list[1];k2=list[2];k3=list[3];k4=list[4];k5=list[5];remark = list[6];jsonstr =  "{'first':{ "\f"    'value':'{first}',"\"    'color':'#173177'"\"},"\"'keyword1': {"\f"    'value':'{k1}',"\"    'color':'#173177'"\"},"\"'keyword2': {"\f"    'value':'{k2}',"\"    'color':'#173177'"\"},"\"'keyword3': {"\f"    'value':'{k3}',"\"    'color':'#173177'"\"},"\"'keyword4': {"\f"    'value':'{k4}',"\"    'color':'#173177'"\"},"\"'keyword5': {"\f"    'value':'{k5}',"\"    'color':'#173177'"\"},"\"'remark':{"\f"    'value':'{remark}',"\"    'color':'#173177'"\"}}";jsonstr = jsonstr.replace("'", "\"")body = "{" + f'"touser":"{userId}", "template_id": "{template_id}", "url":"#", "data":{jsonstr}' + "}";data = json.loads(body);url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;result = httpPost(url, data , "");print(result);def getToken():  print("获取token...")url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + appsecret;result = httpGet(url,"");print(result);global token;token = result["access_token"];#Timer(60*60, getToken).start()def sendMsg():now = datetime.datetime.now()ts = now.strftime('%Y-%m-%d %H:%M:%S')conn1 = pymysql.connect(host="xx.xx.xx.xx",port=3306,user="root",passwd="xxx",db="sxty_data" )cursor1 = conn1.cursor()print(ts + " 获取消息任务")sql = "select to_user,content,id from msg_wx where state = 0 "#print(sql)cursor1.execute(sql)data1 = cursor1.fetchall()#print(data1);for row in data1:userId = row[0];content = row[1];msgId = row[2];send(userId,content);msg = MsgWxModel();msg.cursor = cursor1;msg.conn = conn1;msg.id = msgId;msg.state = 1;msg.send_date = ts;msg.update();cursor1.close();conn1.close();#获取token
def job0():try:getToken();        except Exception as reason:print(reason)pass;Timer(60*60, job0).start();       #发送消息
def job1():try:sendMsg();        except Exception as reason:getToken();print(reason)Timer(5, job1).start();print("消息服务已启动...")
job0();
job1(); #findUser();

http://www.dt0577.cn/news/22187.html

相关文章:

  • 湖南大型网站建设东莞关键词排名提升
  • CP网站建设搭建需要多少钱网站如何宣传推广
  • 网站怎么做百度权重站长工具日本
  • 深圳工信部网站备案最新域名ip地址
  • 网站导航固定域名申请哪家好
  • 幸福人寿保险公司官方网站电子保单打印网站seo好学吗
  • 影楼行业网站seo专业培训技术
  • 光谷做网站推广价格cba排名最新排名
  • 太原网站建设技术外包无锡seo优化
  • 网站建设系统chi系统如何进行百度推广
  • 赣州市建设工程造价管理网站seo快照推广
  • 时时彩网站建设公司德芙巧克力的软文500字
  • wordpress 后台访问慢四川企业seo
  • asp 绿色环保企业网站源码 v1.1百度首页精简版
  • 焦作网站设计做神马seo快速排名软件
  • 网站做软件在什么网站可以免费
  • 手游传奇新开服网站汕头seo按天付费
  • 网站建设 版权归属2023网站推广入口
  • php动态网站制作流程图重庆seo排名
  • 扬州房产网win10最强优化软件
  • 太原智能化营销网站制作公司如何联系百度客服
  • 区政府网站集约化建设合肥做网站哪家好
  • wordpress修改邮箱aso排名优化知识
  • 免费的查企业的网站云浮新增确诊病例30例
  • 毕业设计网站建设软件项目百度推广怎么做步骤
  • 做网站需要哪些参考文献郑州专业的网站公司
  • wordpress淘宝客插件中山seo排名
  • 比价网站模板惠州搜索引擎seo
  • 低价做营销企业网站百度识图识别
  • 婚庆公司收费价格表聊城seo优化