Facebook Python SDK
Project description
Facebook SDK Python
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file facebook-sdk-python-0.0.4.tar.gz
.
File metadata
- Download URL: facebook-sdk-python-0.0.4.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bda0b7d64d206055ec7d5333159ce036625f49be5c70e4b9d6c56b74dde564fd |
|
MD5 | 7b5f7803ccf8e6e6d37ce2170fd66139 |
|
BLAKE2b-256 | cf8b7a806d564b200989632cab1b79b59a6a14adbcabe804bbe3326e90e307a8 |
File details
Details for the file facebook_sdk_python-0.0.4-py2-none-any.whl
.
File metadata
- Download URL: facebook_sdk_python-0.0.4-py2-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 115be61575696321652258e0dfa2cd78070bc59af0e99e81bbd1961ed17ecd3e |
|
MD5 | 3d0d09ca35add51eb0b43ad23bf48cc6 |
|
BLAKE2b-256 | 6b11ab952ead1586b2608ed1fb08dbc79da56f45d0ea2e9fbc7a7ec21517a24f |