def get_mentioned_comment(self): request_url = 'https://api.weibo.com/2/comments/mentions.json' request_params = { 'access_token': self.access_token, } request_url = request_url + '?' + common_tools.dict_to_url_params( request_params) res = common_tools.get(request_url, show_data=False, show_headers=False) res = json.loads(res) if 'error' in res: return return res
def get_auth(self, code): request_url = 'https://api.weibo.com/oauth2/access_token' request_params = { 'client_id': weibo_base.client_id, 'client_secret': weibo_base.client_secret, 'grant_type': 'authorization_code', 'code': code, 'redirect_uri': weibo_base.app_uri } request_url = request_url + '?' + common_tools.dict_to_url_params( request_params) res = common_tools.post(request_url, show_data=False, show_headers=False) res = json.loads(res) self.access_token = res["access_token"] self.end_time = res['expires_in'] self.user_uid = res['uid'] return
def get_value_by_url(url, url_param_dict): url = url + '?' + common_tools.dict_to_url_params(url_param_dict) response = request.urlopen(url) readDct = response.read().decode('utf-8') data = json.loads(readDct) return data