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.

Source Distribution

facebook-sdk-python-0.0.4.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

facebook_sdk_python-0.0.4-py2-none-any.whl (14.0 kB view details)

Uploaded Python 2

File details

Details for the file facebook-sdk-python-0.0.4.tar.gz.

File metadata

File hashes

Hashes for facebook-sdk-python-0.0.4.tar.gz
Algorithm Hash digest
SHA256 bda0b7d64d206055ec7d5333159ce036625f49be5c70e4b9d6c56b74dde564fd
MD5 7b5f7803ccf8e6e6d37ce2170fd66139
BLAKE2b-256 cf8b7a806d564b200989632cab1b79b59a6a14adbcabe804bbe3326e90e307a8

See more details on using hashes here.

File details

Details for the file facebook_sdk_python-0.0.4-py2-none-any.whl.

File metadata

File hashes

Hashes for facebook_sdk_python-0.0.4-py2-none-any.whl
Algorithm Hash digest
SHA256 115be61575696321652258e0dfa2cd78070bc59af0e99e81bbd1961ed17ecd3e
MD5 3d0d09ca35add51eb0b43ad23bf48cc6
BLAKE2b-256 6b11ab952ead1586b2608ed1fb08dbc79da56f45d0ea2e9fbc7a7ec21517a24f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page