Beispiel #1
0
 def refresh_access_token(cls, refresh_token):
     params = {
         "appid": cls.wx_api_config.appid,
         "grant_type": "refresh_token",
         "refresh_token": refresh_token
     }
     return url_requset(cls.wx_api_config._REFRESHTOKRN_URL, params)
Beispiel #2
0
 def jsapi_ticket(cls, access_token):
     '''
     jsapi_ticket的有效期为7200秒,需要进行缓存
     :param access_token:
     :return:
     '''
     params = {"access_token": access_token, "type": "jsapi"}
     return url_requset(cls.wx_api_config._JSAPI_URL, params)
Beispiel #3
0
 def get_access_token(cls):
     '''
     公众号的全局唯一票据
     :return:  需要进行缓存,512个字符空间,有效期2个小时
     '''
     params = {
         "grant_type": "client_credential",
         "appid": cls.wx_api_config.appid,
         "secret": cls.wx_api_config.appsecret
     }
     return url_requset(cls.wx_api_config._ACCESS_URL, params)
Beispiel #4
0
    def get_access_token_by_code(cls, code):
        '''

        :param code:
        :return:
        '''
        params = {
            "appid": cls.wx_api_config.appid,
            "secret": cls.wx_api_config.appsecret,
            "code": code,
            "grant_type": "authorization_code"
        }
        return url_requset(cls.wx_api_config._CODEACCESS_URL, params)
Beispiel #5
0
 def get_user_info(cls, access_token, openid, lang="zh_CN"):
     params = {"access_token": access_token, "openid": openid, "lang": lang}
     return url_requset(cls.wx_api_config._USER_URL, params)
Beispiel #6
0
 def delete_menu(cls, access_token):
     params = {"access_token": access_token}
     return url_requset(cls.wx_api_config._MENU_DELETE_URL, params)
Beispiel #7
0
 def create_menu(cls, data, access_token):
     params = json.dumps(data, ensure_ascii=False)
     url = cls.wx_api_config._SEND_URL, '&access_token=', access_token
     return url_requset(cls.wx_api_config._MENU_CREATE_URL, params, "post")
Beispiel #8
0
 def send(cls, data, access_token):
     params = json.dumps(data, ensure_ascii=False)
     url = cls.wx_api_config._SEND_URL, '&access_token=', access_token
     return url_requset(url, params, "post")
Beispiel #9
0
 def validate_access_token(cls, access_token, openid):
     params = {"access_token": access_token, "openid": openid}
     return url_requset(cls.wx_api_config._VALIDATE_URL, params)