Skip to content

Commit

Permalink
get myself extra fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jmg committed Apr 10, 2018
1 parent 43f7100 commit 677c326
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions pyfb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FacebookClient(object):
GRAPH_URL = "https://graph.facebook.com/"
API_URL = "https://api.facebook.com/"

BASE_AUTH_URL = "%sdialog/oauth?" % FACEBOOK_URL
BASE_AUTH_URL = "%sdialog/oauth?" % FACEBOOK_URL
DIALOG_BASE_URL = "%sdialog/feed?" % FACEBOOK_URL
FBQL_BASE_URL = "%sfql?" % GRAPH_URL
BASE_TOKEN_URL = "%soauth/access_token?" % GRAPH_URL
Expand Down Expand Up @@ -49,7 +49,7 @@ def _make_request(self, url, data=None):
data = None
return urllib.urlopen(url, data).read()

def _make_auth_request(self, path, **data):
def _make_auth_request(self, path, extra_params=None, **data):
"""
Makes a request to the facebook Graph API.
This method requires authentication!
Expand All @@ -60,6 +60,9 @@ def _make_auth_request(self, path, **data):

token_url = "?access_token=%s" % self.access_token
url = "%s%s%s" % (self.GRAPH_URL, path, token_url)
if extra_params:
url = "%s&%s" % (url, extra_params)

if data:
post_data = urllib.urlencode(data)
else:
Expand Down Expand Up @@ -180,11 +183,11 @@ def get_dialog_url(self, redirect_uri):
url = "%s%s" % (self.DIALOG_BASE_URL, url_path)
return url

def get_one(self, path, object_name):
def get_one(self, path, object_name, extra_params=None):
"""
Gets one object
"""
data = self._make_auth_request(path)
data = self._make_auth_request(path, extra_params=extra_params)
obj = self._make_object(object_name, data)

if hasattr(obj, 'error'):
Expand All @@ -201,7 +204,7 @@ def get_list(self, id, path, object_name=None):
if object_name is None:
object_name = path
path = "%s/%s" % (id, path.lower())

obj = self.get_one(path, object_name)
obj_list = self.factory.make_paginated_list(obj, object_name)

Expand Down Expand Up @@ -250,7 +253,7 @@ def execute_fql_query(self, query):
data = self._make_request(url)

objs = self.factory.make_objects_list(table, data)

if hasattr(objs, 'error'):
raise PyfbException(objs.error.message)

Expand Down
4 changes: 2 additions & 2 deletions pyfb/pyfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def set_permissions(self, permissions):
"""
self._client.permissions = permissions

def get_myself(self):
def get_myself(self, extra_params=None):
"""
Gets myself data
"""
return self._client.get_one("me", "FBUser")
return self._client.get_one("me", "FBUser", extra_params=extra_params)

def get_user_by_id(self, id=None):
"""
Expand Down

0 comments on commit 677c326

Please sign in to comment.