Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    fbconsole 0.3

    Download button

    No screenshots available
    Downloads: 215  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Paul Carduner | More programs
    The Apache License 2.0 / FREE
    February 7th, 2012, 14:07 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    fbconsole description

    A simple Facebook API client for writing command-line scripts

    fbconsole is a small Facebook API client for use in Python scripts.

    You can install fbconsole using pip:

    pip install fbconsole

    Or if you don't want to install anything first, just include these lines at the top of your script:

    from urllib import urlretrieve
    import imp
    urlretrieve('https://raw.github.com/facebook/fbconsole/master/src/fbconsole.py',
     '.fbconsole.py')
    fbconsole = imp.load_source('fb', '.fbconsole.py')


    Please take note of the security risks with running code downloaded from the internet like this.

    Quick Start Guide

    Authentication

    For many api calls, you will need to authenticate your script with Facebook. fbconsole makes this easy by providing an authenticate function. If your script needs extended permissions, for example to post a status update, you can specify which extended permissions to request with the AUTH_SCOPE setting. For example:

    import fbconsole

    fbconsole.AUTH_SCOPE = ['publish_stream', 'publish_checkins']
    fbconsole.authenticate()


    You can find a list of permissions in Facebook's api documentation here.

    During the authentication process, a browser window will be opened where you can enter in your facebook login credentials. After logging in, you can close the browser window. Your script will continue executing in the background.

    The access token used for authentication will be stored in a file, so the next time your script is run, the authenticate() function won't have to do anything. To remove this access token, you can call logout():

    fbconsole.logout()

    Graph API Basics

    You can make HTTP POST requests using the post function. Here is how you would update your status:

    status = fbconsole.post('/me/feed', {'message':'Hello from my awesome script'})

    You can make HTTP GET requests using the get function. Here is how you would fetch likes on a status update:

    likes = fbconsole.get('/'+status['id']+'/likes')

    You can make HTTP DELETE requests using the delete function. Here is how you would delete a status message:

    fbconsole.delete('/'+status['id'])

    To upload a photo, you can profile a file-like object as a post parameter:

    fbconsole.post('/me/photos', {'source':open('my-photo.jpg')})

    Finally, you can also make FQL queries using the fql function. For example:

    friends = fbconsole.fql("SELECT name FROM user WHERE uid IN "
     "(SELECT uid2 FROM friend WHERE uid1 = me())")


    More Authentication Options

    By default, fbconsole will make all it's requests as the fbconsole facebook app. If you want the requests to be made by your own facebook application, you must modify the APP_ID setting. For example:

    fbconsole.APP_ID = '< your-app-id >'
    fbconsole.authenticate()


    For the authentication flow to work, you must configure your Facebook application correctly by setting the "Site URL" option to http://127.0.0.1:8080

    If you don't want to change your application settings, you can also specify an access token to use directly, in which case you can skip authentication altogether:

    fbconsole.ACCESS_TOKEN = '< your-access-token >'

    Other Options

    There are two other options you can specify.

    - SERVER_PORT controls which port the local server runs on. If you modify this, make sure your applications settings on Facebook, specifically "Site URL", reflect the port number you are using. The default is 8080.

    - ACCESS_TOKEN_FILE controls where the access token gets stored on the file system. The default is .fb_access_token.


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    Facebook API | Python library | command-line scripts | Python | Facebook | API

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM