def wrap(**kw): at = attr[1:] if attr[0] == '_' else attr url = BASE_URL % (at.replace('__', '/'), self.__access_token) method = 'GET' param = '' if kw: if 'method' in kw: method = kw['method'] del kw['method'] else: method = 'GET' param = '&'.join([ '%s=%s' % (i, quote(j, safe='()')) for i, j in kw.iteritems() ]) if method == 'GET': if param: url += '&' + param result = urlfetch.fetch(url).content elif method == 'POST': result = urlfetch.fetch(url, payload=param, method=urlfetch.POST).content result = code.json_to_object(result) return result
def get(self): self.response.headers['Content-Type'] = 'text/plain' data = {} res = urlfetch.fetch(make_access_token_url(self.request.get('code'))) res = util.urldecode(res.content) data['access_token'] = res['access_token'] data['expire_in'] = int(res['expires']) data['account_type'] = 'facebook' res = code.json_to_object(urlfetch.fetch(BASE_URL%('me', data['access_token'])).content) data['account_name'] = str(res['id']) util.redirect_to_login(self, data)
def get(self): self.response.headers['Content-Type'] = 'text/plain' data = {} res = urlfetch.fetch(make_access_token_url(self.request.get('code'))) res = util.urldecode(res.content) data['access_token'] = res['access_token'] data['expire_in'] = int(res['expires']) data['account_type'] = 'facebook' res = code.json_to_object( urlfetch.fetch(BASE_URL % ('me', data['access_token'])).content) data['account_name'] = str(res['id']) util.redirect_to_login(self, data)
def wrap(**kw): at = attr[1:] if attr[0] == "_" else attr url = BASE_URL % (at.replace("__", "/"), self.__access_token) method = "GET" param = "" if kw: if "method" in kw: method = kw["method"] del kw["method"] else: method = "GET" param = "&".join(["%s=%s" % (i, quote(j, safe="()")) for i, j in kw.iteritems()]) if method == "GET": if param: url += "&" + param result = urlfetch.fetch(url).content elif method == "POST": result = urlfetch.fetch(url, payload=param, method=urlfetch.POST).content result = code.json_to_object(result) return result
def wrap(**kw): url = BASE_URL % (attr.replace('__','/'), self.__access_token)+ \ urllib.urlencode(kw) result = urlfetch.fetch(url).content result = code.json_to_object(result) return result