From ba2cc91d7ab39ad2307c18f822eaf9fd17bfe029 Mon Sep 17 00:00:00 2001 From: Juan Manuel Garcia Date: Wed, 4 Sep 2019 00:01:15 -0300 Subject: [PATCH] add raw request method to client --- pyfb/__init__.py | 2 +- pyfb/client.py | 8 +++++++- pyfb/pyfb.py | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pyfb/__init__.py b/pyfb/__init__.py index 69d8421..2c8e3df 100644 --- a/pyfb/__init__.py +++ b/pyfb/__init__.py @@ -14,7 +14,7 @@ # MA 02110-1301, USA. __author__ = "Juan Manuel Garcia" -__version__ = "0.4.3" +__version__ = "0.4.4" __license__ = 'GPL v3' from pyfb import Pyfb, PyfbException diff --git a/pyfb/client.py b/pyfb/client.py index 1c83c6d..3ad4d3a 100755 --- a/pyfb/client.py +++ b/pyfb/client.py @@ -58,7 +58,13 @@ def _make_auth_request(self, path, extra_params=None, **data): if self.access_token is None: raise PyfbException("Must Be authenticated. Did you forget to get the access token?") - token_url = "?access_token=%s" % self.access_token + if "?" not in path: + sep = "?" + else: + sep = "&" + + token_url = "%saccess_token=%s" % (sep, self.access_token) + url = "%s%s%s" % (self.GRAPH_URL, path, token_url) if extra_params: url = "%s&%s" % (url, extra_params) diff --git a/pyfb/pyfb.py b/pyfb/pyfb.py index 7ee1777..c9f03d4 100644 --- a/pyfb/pyfb.py +++ b/pyfb/pyfb.py @@ -7,6 +7,7 @@ import webbrowser from client import FacebookClient, PyfbException +import json class Pyfb(object): """ @@ -174,3 +175,10 @@ def fql_query(self, query): Executes a FBQL query """ return self._client.execute_fql_query(query) + + def request(self, path, **data): + """ + Executes a request to the api + """ + response = self._client._make_auth_request(path, **data) + return json.loads(response)