Пример #1
0
    def __init__(self,
                 app_id,
                 access_token=None,
                 raw_data=False,
                 permissions=None):

        self._client = FacebookClient(app_id,
                                      access_token=access_token,
                                      raw_data=raw_data,
                                      permissions=permissions)
Пример #2
0
    def __init__(self, app_id, access_token=None, raw_data=False):

        self._client = FacebookClient(app_id, access_token, raw_data)
Пример #3
0
class Pyfb(object):
    """
        This class is Facade for FacebookClient
    """

    def __init__(self, app_id, access_token=None, raw_data=False):

        self._client = FacebookClient(app_id, access_token, raw_data)

    def authenticate(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_url())

    def get_authentication_code(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_code_url())

    def get_auth_url(self, redirect_uri=None):
        """
            Returns the authentication url
        """
        return self._client.get_auth_token_url(redirect_uri)

    def get_auth_code_url(self, redirect_uri=None, state=None):
        """
            Returns the url to get a authentication code
        """
        return self._client.get_auth_code_url(redirect_uri, state=state)

    def get_access_token(self, app_secret_key, secret_code, redirect_uri=None):
        """
            Gets the access token
        """
        return self._client.get_access_token(app_secret_key, secret_code, redirect_uri)

    def exchange_token(self, app_secret_key, exchange_token):
        """
             Exchanges a short-lived access token (like those obtained from client-side JS api)
             for a longer-lived access token
        """
        return self._client.exchange_token(app_secret_key, exchange_token)

    def show_dialog(self, redirect_uri=None):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_dialog_url(redirect_uri=redirect_uri))

    def get_dialog_url(self, redirect_uri=None):
        """
            Returns a url inside facebook that shows a dialog allowing
            users to publish contents.
        """
        return self._client.get_dialog_url(redirect_uri)

    def _show_in_browser(self, url):
        """
            Opens your prefered web browser to make the authentication request
        """
        webbrowser.open(url)

    def set_access_token(self, token):
        """
            Sets the access token. Necessary to make the requests that requires autenthication
        """
        self._client.access_token = token

    def set_permissions(self, permissions):
        """
            Sets a list of data access permissions that the user must give to the application
            e.g:
                permissions = [auth.USER_ABOUT_ME, auth.USER_LOCATION, auth.FRIENDS_PHOTOS, ...]
        """
        self._client.permissions = permissions

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

    def get_user_by_id(self, id=None):
        """
            Gets an user by the id
        """
        if id is None:
            id = "me"
        return self._client.get_one(id, "FBUser")

    def get_friends(self, id=None):
        """
            Gets a list with your friends
        """
        return self._client.get_list(id, "Friends")

    def get_statuses(self, id=None):
        """
            Gets a list of status objects
        """
        return self._client.get_list(id, "Statuses")

    def get_photos(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Photos")

    def get_comments(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Comments")

    def publish(self, message, id=None, **kwargs):
        """
            Publishes a message on the wall
        """
        return self._client.push(id, "feed", message=message, **kwargs)

    def comment(self, message, id=None, **kwargs):
        """
            Publishes a message on the wall
        """
        return self._client.push(id, "comments", message=message, **kwargs)

    def get_likes(self, id=None):
        """
            Get a list of liked objects
        """
        return self._client.get_list(id, "likes")

    def like(self, id):
        """
            LIKE: It Doesn't work. Seems to be a bug on the Graph API
            http://bugs.developers.facebook.net/show_bug.cgi?id=10714
        """
        print self.like.__doc__
        return self._client.push(id, "likes")

    def delete(self, id):
        """
            Deletes a object
        """
        return self._client.delete(id)

    def fql_query(self, query):
        """
            Executes a FBQL query
        """
        return self._client.execute_fql_query(query)
Пример #4
0
    def __init__(self, app_id, access_token=None, raw_data=False):

        self._client = FacebookClient(app_id, access_token, raw_data)
Пример #5
0
class Pyfb(object):
    """
        This class is Facade for FacebookClient
    """
    def __init__(self, app_id, access_token=None, raw_data=False):

        self._client = FacebookClient(app_id, access_token, raw_data)

    def authenticate(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_url())

    def get_authentication_code(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_code_url())

    def get_auth_url(self, redirect_uri=None):
        """
            Returns the authentication url
        """
        return self._client.get_auth_token_url(redirect_uri)

    def get_auth_code_url(self, redirect_uri=None, state=None):
        """
            Returns the url to get a authentication code
        """
        return self._client.get_auth_code_url(redirect_uri, state=state)

    def get_access_token(self, app_secret_key, secret_code, redirect_uri=None):
        """
            Gets the access token
        """
        return self._client.get_access_token(app_secret_key, secret_code,
                                             redirect_uri)

    def exchange_token(self, app_secret_key, exchange_token):
        """
             Exchanges a short-lived access token (like those obtained from client-side JS api)
             for a longer-lived access token
        """
        return self._client.exchange_token(app_secret_key, exchange_token)

    def show_dialog(self, redirect_uri=None):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_dialog_url(redirect_uri=redirect_uri))

    def get_dialog_url(self, redirect_uri=None):
        """
            Returns a url inside facebook that shows a dialog allowing
            users to publish contents.
        """
        return self._client.get_dialog_url(redirect_uri)

    def _show_in_browser(self, url):
        """
            Opens your prefered web browser to make the authentication request
        """
        webbrowser.open(url)

    def set_access_token(self, token):
        """
            Sets the access token. Necessary to make the requests that requires autenthication
        """
        self._client.access_token = token

    def set_permissions(self, permissions):
        """
            Sets a list of data access permissions that the user must give to the application
            e.g:
                permissions = [auth.USER_ABOUT_ME, auth.USER_LOCATION, auth.FRIENDS_PHOTOS, ...]
        """
        self._client.permissions = permissions

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

    def get_user_by_id(self, id=None):
        """
            Gets an user by the id
        """
        if id is None:
            id = "me"
        return self._client.get_one(id, "FBUser")

    def get_friends(self, id=None):
        """
            Gets a list with your friends
        """
        return self._client.get_list(id, "Friends")

    def get_statuses(self, id=None):
        """
            Gets a list of status objects
        """
        return self._client.get_list(id, "Statuses")

    def get_photos(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Photos")

    def get_comments(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Comments")

    def publish(self, message, id=None, **kwargs):
        """
            Publishes a message on the wall
        """
        return self._client.push(id, "feed", message=message, **kwargs)

    def comment(self, message, id=None, **kwargs):
        """
            Publishes a message on the wall
        """
        return self._client.push(id, "comments", message=message, **kwargs)

    def get_likes(self, id=None):
        """
            Get a list of liked objects
        """
        return self._client.get_list(id, "likes")

    def like(self, id):
        """
            LIKE: It Doesn't work. Seems to be a bug on the Graph API
            http://bugs.developers.facebook.net/show_bug.cgi?id=10714
        """
        print self.like.__doc__
        return self._client.push(id, "likes")

    def delete(self, id):
        """
            Deletes a object
        """
        return self._client.delete(id)

    def fql_query(self, query):
        """
            Executes a FBQL query
        """
        return self._client.execute_fql_query(query)
Пример #6
0
    def __init__(self, app_id, access_token=None, raw_data=False, permissions=None):

        self._client = FacebookClient(app_id, access_token=access_token, raw_data=raw_data, permissions=permissions)
Пример #7
0
    def __init__(self, app_id, access_token=None, timeout=30):

        self._client = FacebookClient(app_id, access_token, timeout=timeout)
Пример #8
0
class Pyfb(object):
    """
        This class is Facade for FacebookClient
    """
    def __init__(self, app_id, access_token=None, timeout=30):

        self._client = FacebookClient(app_id, access_token, timeout=timeout)

    def authenticate(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_url())

    def get_authentication_code(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_code_url())

    def get_auth_url(self, redirect_uri=None):
        """
            Returns the authentication url
        """
        return self._client.get_auth_token_url(redirect_uri)

    def get_auth_code_url(self, redirect_uri=None):
        """
            Returns the url to get a authentication code
        """
        return self._client.get_auth_code_url(redirect_uri)

    def get_access_token(self, app_secret_key, secret_code, redirect_uri=None):
        """
            Gets the access token
        """
        return self._client.get_access_token(app_secret_key, secret_code,
                                             redirect_uri)

    def show_dialog(self, redirect_uri=None):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_dialog_url(redirect_uri=redirect_uri))

    def get_dialog_url(self, redirect_uri=None):
        """
            Returns a url inside facebook that shows a dialog allowing
            users to publish contents.
        """
        return self._client.get_dialog_url(redirect_uri)

    def _show_in_browser(self, url):
        """
            Opens your prefered web browser to make the authentication request
        """
        webbrowser.open(url)

    def get_picture_url(self, id, ssl=False, auth=False, size=None):
        """Returns the url of a profile picture.

        :param ssl: True if the picture needs to be returned over a secure connection.
        :param auth: True if authentication is required.
        :param size: Can be:
            - a predefined string ("square", "small", "normal", "large")
            - or a (width, height) tuple
            - or a single integer for square picture (width == height)
        """
        return self._client.get_picture_url(id, ssl=ssl, auth=auth, size=size)

    def set_access_token(self, token):
        """
            Sets the access token. Necessary to make the requests that requires autenthication
        """
        self._client.access_token = token

    def set_permissions(self, permissions):
        """
            Sets a list of data access permissions that the user must give to the application
            e.g:
                permissions = [auth.USER_ABOUT_ME, auth.USER_LOCATION, auth.FRIENDS_PHOTOS, ...]
        """
        self._client.permissions = permissions

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

    def get_user_by_id(self, id=None, fields=None):
        """
            Gets an user by the id
        """
        if id is None:
            id = "me"
        return self._client.get_one(id, "FBUser", fields=fields)

    def get_friends(self, id=None, fields=None, limit=None, offset=None):
        """
            Gets a list with your friends
        """
        return self._client.get_list(id,
                                     "Friends",
                                     fields=fields,
                                     limit=limit,
                                     offset=offset)

    def get_statuses(self, id=None):
        """
            Gets a list of status objects
        """
        return self._client.get_list(id, "Statuses")

    def get_photos(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Photos")

    def get_comments(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Comments")

    def publish(self, message, id=None, **kwargs):
        """
            Publishes a message on the wall
        """
        self._client.post(id, "feed", message=message, **kwargs)

    def action(self,
               namespace,
               action_type_name,
               object_type_name,
               object_url,
               id=None,
               **kwargs):
        """
            Publishes a message on the wall
        """
        self._client.post(id, "%s:%s" % (namespace, action_type_name),
                          **{object_type_name: object_url})

    def comment(self, message, id=None):
        """
            Publishes a message on the wall
        """
        self._client.push(id, "comments", message=message)

    def get_likes(self, id=None):
        """
            Get a list of liked objects
        """
        return self._client.get_list(id, "likes")

    def like(self, id):
        """
            LIKE: It Doesn't work. Seems to be a bug on the Graph API
            http://bugs.developers.facebook.net/show_bug.cgi?id=10714
        """
        print self.like.__doc__
        return self._client.push(id, "likes")

    def delete(self, id):
        """
            Deletes a object
        """
        self._client.delete(id)

    def fql_query(self, query):
        """
            Executes a FBQL query
        """
        return self._client.execute_fql_query(query)
Пример #9
0
Файл: pyfb.py Проект: holm/pyfb
    def __init__(self, app_id, access_token=None, timeout=30):

        self._client = FacebookClient(app_id, access_token, timeout=timeout)
Пример #10
0
Файл: pyfb.py Проект: holm/pyfb
class Pyfb(object):
    """
        This class is Facade for FacebookClient
    """

    def __init__(self, app_id, access_token=None, timeout=30):

        self._client = FacebookClient(app_id, access_token, timeout=timeout)

    def authenticate(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_url())

    def get_authentication_code(self):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_auth_code_url())

    def get_auth_url(self, redirect_uri=None):
        """
            Returns the authentication url
        """
        return self._client.get_auth_token_url(redirect_uri)

    def get_auth_code_url(self, redirect_uri=None):
        """
            Returns the url to get a authentication code
        """
        return self._client.get_auth_code_url(redirect_uri)

    def get_access_token(self, app_secret_key, secret_code, redirect_uri=None):
        """
            Gets the access token
        """
        return self._client.get_access_token(app_secret_key, secret_code, redirect_uri)

    def show_dialog(self, redirect_uri=None):
        """
            Open your prefered web browser to make the authentication request
        """
        self._show_in_browser(self.get_dialog_url(redirect_uri=redirect_uri))

    def get_dialog_url(self, redirect_uri=None):
        """
            Returns a url inside facebook that shows a dialog allowing
            users to publish contents.
        """
        return self._client.get_dialog_url(redirect_uri)

    def _show_in_browser(self, url):
        """
            Opens your prefered web browser to make the authentication request
        """
        webbrowser.open(url)

    def get_picture_url(self, id, ssl=False, auth=False, size=None):
        """Returns the url of a profile picture.

        :param ssl: True if the picture needs to be returned over a secure connection.
        :param auth: True if authentication is required.
        :param size: Can be:
            - a predefined string ("square", "small", "normal", "large")
            - or a (width, height) tuple
            - or a single integer for square picture (width == height)
        """
        return self._client.get_picture_url(id, ssl=ssl, auth=auth, size=size)

    def set_access_token(self, token):
        """
            Sets the access token. Necessary to make the requests that requires autenthication
        """
        self._client.access_token = token

    def set_permissions(self, permissions):
        """
            Sets a list of data access permissions that the user must give to the application
            e.g:
                permissions = [auth.USER_ABOUT_ME, auth.USER_LOCATION, auth.FRIENDS_PHOTOS, ...]
        """
        self._client.permissions = permissions

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

    def get_user_by_id(self, id=None, fields=None):
        """
            Gets an user by the id
        """
        if id is None:
            id = "me"
        return self._client.get_one(id, "FBUser", fields=fields)

    def get_friends(self, id=None, fields=None, limit=None, offset=None):
        """
            Gets a list with your friends
        """
        return self._client.get_list(id, "Friends", fields=fields, limit=limit, offset=offset)

    def get_statuses(self, id=None):
        """
            Gets a list of status objects
        """
        return self._client.get_list(id, "Statuses")

    def get_photos(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Photos")

    def get_comments(self, id=None):
        """
            Gets a list of photos objects
        """
        return self._client.get_list(id, "Comments")

    def publish(self, message, id=None, **kwargs):
        """
            Publishes a message on the wall
        """
        self._client.post(id, "feed", message=message, **kwargs)

    def action(self, namespace, action_type_name, object_type_name, object_url, id=None, **kwargs):
        """
            Publishes a message on the wall
        """
        self._client.post(id, "%s:%s" % (namespace, action_type_name), **{object_type_name: object_url})

    def comment(self, message, id=None):
        """
            Publishes a message on the wall
        """
        self._client.push(id, "comments", message=message)

    def get_likes(self, id=None):
        """
            Get a list of liked objects
        """
        return self._client.get_list(id, "likes")

    def like(self, id):
        """
            LIKE: It Doesn't work. Seems to be a bug on the Graph API
            http://bugs.developers.facebook.net/show_bug.cgi?id=10714
        """
        print self.like.__doc__
        return self._client.push(id, "likes")

    def delete(self, id):
        """
            Deletes a object
        """
        self._client.delete(id)

    def fql_query(self, query):
        """
            Executes a FBQL query
        """
        return self._client.execute_fql_query(query)