示例#1
0
def get_menu(account):
    token_rst = get_access_token(account)
    if token_rst.get("access_token", None):  # 获取到了tocken
        url = WXAPI.MENU_GET_GET + "?access_token=%s" % token_rst["access_token"]
        return json.loads(HttpClient.exePost(url))
    else:
        return token_rst
示例#2
0
def get_access_token(account):
    url = WXAPI.ACCESS_TOKEN_GET + "?grant_type=%s&appid=%s&secret=%s" % (
        account.granttype,
        account.appid,
        account.appsecret,
    )
    return json.loads(HttpClient.exeGet(url))
示例#3
0
def delete_menu(account):
    token_rst = get_access_token(account)
    if token_rst.get("access_token", None):  # 获取到了tocken
        url = WXAPI.MENU_DELETE_GET + "?access_token=%s" % token_rst["access_token"]
        return json.loads(HttpClient.exeGet(url))
    else:  # 返回的是错误代码信息
        return token_rst
示例#4
0
def get_menu(account):
    token_rst = get_access_token(account)
    if token_rst.get('access_token', None):  #获取到了tocken
        url = WXAPI.MENU_GET_GET + '?access_token=%s' % token_rst[
            'access_token']
        return json.loads(HttpClient.exePost(url))
    else:
        return token_rst
示例#5
0
def delete_menu(account):
    token_rst = get_access_token(account)
    if token_rst.get('access_token', None):  #获取到了tocken
        url = WXAPI.MENU_DELETE_GET + '?access_token=%s' % token_rst[
            'access_token']
        return json.loads(HttpClient.exeGet(url))
    else:  #返回的是错误代码信息
        return token_rst
示例#6
0
def create_menu(account, data):
    token_rst = get_access_token(account)
    if token_rst.get("access_token", None):  # 获取到了tocken
        url = WXAPI.MENU_CREATE_POST + "?access_token=%s" % token_rst["access_token"]
        if isinstance(data, unicode):
            data = data.encode("UTF-8")
        rst_json = HttpClient.exePost(url, data)
        return json.loads(rst_json)
    else:  # 返回的是错误代码信息
        return token_rst
示例#7
0
def create_menu(account, data):
    token_rst = get_access_token(account)
    if token_rst.get('access_token', None):  #获取到了tocken
        url = WXAPI.MENU_CREATE_POST + '?access_token=%s' % token_rst[
            'access_token']
        if isinstance(data, unicode):
            data = data.encode('UTF-8')
        rst_json = HttpClient.exePost(url, data)
        return json.loads(rst_json)
    else:  #返回的是错误代码信息
        return token_rst
示例#8
0
def get_access_token(account):
    url = WXAPI.ACCESS_TOKEN_GET + '?grant_type=%s&appid=%s&secret=%s' % (
        account.granttype, account.appid, account.appsecret)
    return json.loads(HttpClient.exeGet(url))