himalaya.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:wechat 作者: tianyongchina 项目源码 文件源码
def get_access_token(self):
        params = {}
        params['client_id'] = self.__app_key
        params['grant_type'] = "client_credentials"
        params['device_id']= self.__device_id
        params['timestamp'] = long(time.time() * 1000)
        tmp_num = float(str(params['timestamp'])[8:])
        params['nonce'] = str(tmp_num * tmp_num)
        data = self.__sig_calc(params)

        body = data[1]
        tmp_url = self.__access_token_url
        """
        resp = urllib.urlopen(tmp_url, body).read()
        res = json.loads(resp)
        """
        res = self.http_post(tmp_url, body, 'application/x-www-form-urlencoded')
        if res is None:
            return
        #print ("==>>> get_access_token_resp:%s"%(res))
        log.debug("get_access_token response:%s"%(res))
        if not res.has_key('error_no'):
            self.__access_token = res['access_token']
            self.__expires_in = res['expires_in']
        else:
            self.__access_token = ''
            self.__expires_in = 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号