Skip to main content

Facebook Python SDK

Project description

Facebook SDK Python

https://travis-ci.org/zetahernandez/facebook-python-sdk.svg?branch=master https://coveralls.io/repos/github/zetahernandez/facebook-python-sdk/badge.svg

Facebook SDK Python is a python based implementation of Facebook PHP SDK

Installation

To install Facebook SDK Python, simply:

$ pip install facebook-sdk-python

Usage

Retrieve User Profile

from facebook_sdk.exceptions import FacebookResponseException
from facebook_sdk.facebook import Facebook

facebook = Facebook(
    app_id='{app_id}',
    app_secret='{app_secret}',
    default_graph_version='v2.5',
)

facebook.set_default_access_token(access_token='{access_token}')

try:
    response = facebook.get(endpoint='/me?fields=id,name')
except FacebookResponseException as e:
    print e.message
else:
    print 'User name: %(name)s' % {'name': response.json_body.get('id')}

Batch Upload Files

from facebook_sdk.exceptions import FacebookResponseException
from facebook_sdk.facebook import Facebook

facebook = Facebook(
    app_id='{app_id}',
    app_secret='{app_secret}',
)

facebook.set_default_access_token(access_token='{access_token}')

batch = {
    'photo-one': facebook.request(
        endpoint='/me/photos',
        params={
            'message': 'Foo photo.',
            'source': facebook.file_to_upload('path/to/foo.jpg'),
        },
    ),
    'photo-two': facebook.request(
        endpoint='/me/photos',
        params={
            'message': 'Bar photo.',
            'source': facebook.file_to_upload('path/to/bar.jpg'),
        },
    ),
    'photo-three': facebook.request(
        endpoint='/me/photos',
        params={
            'message': 'Other photo.',
            'source': facebook.file_to_upload('path/to/other.jpg'),
        },
    )
}

try:
    responses = facebook.send_batch_request(requests=batch)
except FacebookResponseException as e:
    print e.message

Dependencies

Dependencies that to use the application:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
facebook_sdk_python-0.0.4-py2-none-any.whl (14.0 kB) Copy SHA256 hash SHA256 Wheel 2.7
facebook-sdk-python-0.0.4.tar.gz (9.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page