Skip to content

Commit

Permalink
add raw request method to client
Browse files Browse the repository at this point in the history
  • Loading branch information
jmg committed Sep 4, 2019
1 parent 677c326 commit ba2cc91
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyfb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion pyfb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions pyfb/pyfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import webbrowser
from client import FacebookClient, PyfbException
import json

class Pyfb(object):
"""
Expand Down Expand Up @@ -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)

0 comments on commit ba2cc91

Please sign in to comment.