예제 #1
0
파일: media.py 프로젝트: kerol/weixin-api
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)
예제 #2
0
파일: message.py 프로젝트: kerol/weixin-api
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)
예제 #3
0
파일: ticket.py 프로젝트: kerol/weixin-api
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
파일: auth.py 프로젝트: kerol/weixin-api
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)
예제 #7
0
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)
예제 #8
0
파일: auth.py 프로젝트: kerol/weixin-api
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)
예제 #9
0
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)