def accessToken(self): parameters = self._oauth_parameter() base_url = ACCESS_TOKEN_BASE_URL s = self._sig_request_url(base_url, parameters) rf = urllib.urlopen(s) status = rf.getcode() if status == 200: d = json.loads(rf.read()) for k in (u"oauth_token", u"oauth_token_secret", u"user_id", u"charged_dir"): if d.has_key(k): v = d.get(k) setattr(self, to_string(k), safe_value(v)) else: raise OpenAPIHTTPError(status, rf.read())
def requestToken(self, callback=None): parameters = self._oauth_parameter(has_token=False) if callback: parameters['oauth_callback'] = callback base_url = REQUEST_TOKEN_BASE_URL s = self._sig_request_url(base_url, parameters) rf = urllib.urlopen(s) status = rf.getcode() if status == 200: d = json.loads(rf.read()) for k in (u"oauth_token", u"oauth_token_secret", u"oauth_callback_confirmed"): if d.has_key(k): v = d.get(k) setattr(self, to_string(k), safe_value(v)) else: raise OpenAPIHTTPError(status, rf.read())
def account_info(self): parameters = self._oauth_parameter() base_url = ACCOUNT_INFO_BASE_URL s = self._sig_request_url(base_url, parameters) rf = urllib.urlopen(s) status = rf.getcode() if status == 200: d = json.loads(rf.read()) for k in (u"max_file_size", u"user_name", u"user_id", u"quota_total", u"quota_used", u"quota_recycled"): if d.has_key(k): v = d.get(k) setattr(self, to_string(k), safe_value(v)) else: raise OpenAPIHTTPError(status, rf.read())