def get(access_token, media_id, **kwargs): """ 获取临时素材 """ api = 'https://api.weixin.qq.com/cgi-bin/media/get' params = {'access_token': access_token, 'media_id': media_id} params.update(**kwargs) return requests_get(api, params)
def wxopen_activityid_create(access_token, params=None, **kwargs): """ 创建被分享动态消息的 activity_id """ api = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/activityid/create?access_token={}'.format( access_token) params = {} if not params else params.update(**kwargs) return requests_get(api, params)
def getticket(access_token, ticket_type, params=None, **kwargs): """ 获取api_ticket """ api = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={}&type={}'.format( access_token, ticket_type) params = {} if not params else params.update(**kwargs) return requests_get(api, params)
def userinfo(access_token, openid): """ 拉取用户信息 """ api = 'https://api.weixin.qq.com/sns/userinfo' params = { 'access_token': access_token, 'openid': openid, } return requests_get(api, params)
def auth(access_token, openid): """ 检验授权凭证(access_token)是否有效 """ api = 'https://api.weixin.qq.com/sns/auth' params = { 'access_token': access_token, 'openid': openid, } return requests_get(api, params)
def access_token(app_id, secret): api = 'https://api.weixin.qq.com/cgi-bin/token' params = { 'appid': app_id, 'secret': secret, 'grant_type': 'client_credential', } return requests_get(api, params)
def refresh_token(app_id, refresh_token): """ 刷新access_token """ api = 'https://api.weixin.qq.com/sns/oauth2/refresh_token' params = { 'appid': app_id, 'grant_type': 'refresh_token', 'refresh_token': refresh_token, } return requests_get(api, params)
def jscode2session(app_id, secret, js_code): """ 临时登录凭证校验接口 """ api = 'https://api.weixin.qq.com/sns/jscode2session' params = { 'appid': app_id, 'secret': secret, 'js_code': js_code, 'grant_type': 'authorization_code', } return requests_get(api, params)
def access_token(app_id, secret, code): """ 通过code换取网页授权access_token """ api = 'https://api.weixin.qq.com/sns/oauth2/access_token' params = { 'appid': app_id, 'secret': secret, 'code': code, 'grant_type': 'authorization_code', } return requests_get(api, params)