素材:
- 注册 微信公众平台的订阅号
- 开通开发者中心功能,注册公众平台测试账号。获取到appID和appsecret
摘要:
- 使用Python 2.7
- 基于 微信‘公众平台测试账号’的appID和appsecret实现自动刷新 access_token,和(根据接收列表)发送消息的功能
代码:
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 03 21:24:18 2017
@author: Selay
"""
import requests
import json
import threading
# 字典allusers用于存储 由 索引名和openID构成的键值对
# 微信关注‘测试号’时,会生成openID用于与对应微信账号通讯
# 索引名 是为了便于自己识别和管理而对openID起的别名
allusers = {
'大大':'eXIuShYFO7tghjb_4YWA'}
def usersto(users = None):
if users == None:
return allusers['大大']
elif users == "All":
return ','.join(set(allusers.values()))