Python SDK for Facebook's Graph API

Overview

Facebook Python SDK

This client library is designed to support the Facebook Graph API and the official Facebook JavaScript SDK, which is the canonical way to implement Facebook authentication. You can read more about the Graph API by accessing its official documentation.

Licensing

This library uses the Apache License, version 2.0. Please see the library's individual files for more information.

Reporting Issues

If you have bugs or other issues specifically pertaining to this library, file them here. Bugs with the Graph API should be filed on Facebook's bugtracker.

Support & Discussion

Documentation is available at https://facebook-sdk.readthedocs.io/en/latest/.

Have a question? Need help? Visit the library's Google Group.

Comments
  • Add function for retrieving user permissions

    Add function for retrieving user permissions

    This adds a function get_permissions() that returns the user permissions from the Graph API. To use this you must supply a user token.

    For testing, set the environment variable FACEBOOK_USER_ACCESS_TOKEN to a token retrieved from the Graph API explorer... if this is not set then the test will be skipped.

    enhancement 
    opened by seawolf42 29
  • Error with put_photo - UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 413: ordinal not in range(128)

    Error with put_photo - UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 413: ordinal not in range(128)

    (Pdb) image
    <open file '/home/sontek/.virtualenvs/studiosnaps/src/studiosnaps/booth/photos/uploads/upload_11.jpg', mode 'r' at 0x147f4b0>
    (Pdb) c
    

    Traceback (most recent call last): File "/home/sontek/.virtualenvs/studiosnaps/local/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run result = self._run(_self.args, *_self.kwargs) File "/home/sontek/.virtualenvs/studiosnaps/src/studiosnaps/booth/controller.py", line 114, in upload_photo self.uploader.upload_photo(self.view.get_upload_file()) File "/home/sontek/.virtualenvs/studiosnaps/src/studiosnaps/booth/upload.py", line 283, in upload_photo photo_response = fp_graph.put_photo(photo, '', album_id) File "/home/sontek/.virtualenvs/studiosnaps/src/studiosnaps/booth/facebook.py", line 175, in put_photo object_id = album_id or "me" File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 400, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 418, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 1215, in https_open return self.do_open(httplib.HTTPSConnection, req) File "/usr/lib/python2.7/urllib2.py", line 1174, in do_open h.request(req.get_method(), req.get_selector(), req.data, headers) File "/usr/lib/python2.7/httplib.py", line 958, in request self._send_request(method, url, body, headers) File "/usr/lib/python2.7/httplib.py", line 992, in _send_request self.endheaders(body) File "/usr/lib/python2.7/httplib.py", line 954, in endheaders self._send_output(message_body) File "/usr/lib/python2.7/httplib.py", line 812, in _send_output msg += message_body UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 413: ordinal not in range(128)

    I'm just calling:

                photo_response = graph_obj.put_photo(photo, '', album_id)
    
    opened by sontek 12
  • GraphAPIError: Code was invalid or expired.

    GraphAPIError: Code was invalid or expired.

    This happens when using the Facebook JavaScript SDK to generate a cookie. So in other words, it should be providing a fresh cookie always. Reloading the page fixes this issue but this is obviously not ideal UX and leads most users to think the site is broken.

    Exception on /facebook/login [GET] Traceback (most recent call last): File "/srv/http/blueprint/trekseat/lib/python2.7/site-packages/flask/app.py", line 1504, in wsgi_app response = self.full_dispatch_request() File "/srv/http/blueprint/trekseat/lib/python2.7/site-packages/flask/app.py", line 1264, in full_dispatch_request rv = self.handle_user_exception(e) File "/srv/http/blueprint/trekseat/lib/python2.7/site-packages/flask/app.py", line 1262, in full_dispatch_request rv = self.dispatch_request() File "/srv/http/blueprint/trekseat/lib/python2.7/site-packages/flask/app.py", line 1248, in dispatch_request return self.view_functionsrule.endpoint File "/srv/http/blueprint/trekseat/frontend/views.py", line 799, in facebook_login local user and determine if we should create a new user, in the case none File "/srv/http/blueprint/trekseat/src/facebook-sdk/facebook.py", line 366, in get_user_from_cookie app_id, app_secret) File "/srv/http/blueprint/trekseat/src/facebook-sdk/facebook.py", line 434, in get_access_token_from_code response["error"]["message"]) GraphAPIError: Code was invalid or expired. Session has expired at unix time 1325545200. The current unix time is 1325556761.

    opened by maxcountryman 11
  • Cheeseshop mirror broken?

    Cheeseshop mirror broken?

       Downloading/unpacking facebook-sdk (from -r requirements.txt (line 4))
       Could not find any downloads that satisfy the requirement facebook-sdk (from -r requirements.txt (line 4))
       No distributions at all found for facebook-sdk (from -r requirements.txt (line 4))
       Storing complete log in /app/.pip/pip.log
    
    opened by nisc 11
  • pip install version not installing latest

    pip install version not installing latest

    attempting to install version 2.0.0 to get the latest Facebook SDK versions but even when i do sudo pip install facebook-sdk --upgrade or if i do sudo pip install facebook-sdk==2.0.0 it ALWAYS installs 1.0.0

    opened by jwwtaker 10
  • debug_access_token does not work if self.access_token is set

    debug_access_token does not work if self.access_token is set

    While debugging token, if we need to verify a token against an app, the implementation seems to give error.

    This is due to override of 'access_token' in arguments in request method.

    See:

    https://github.com/pythonforfacebook/facebook-sdk/blob/master/facebook/init.py#L236

    bug 
    opened by sagarchalise 10
  • Google App Engine RuntimeError: error('illegal IP address string passed to inet_pton',)

    Google App Engine RuntimeError: error('illegal IP address string passed to inet_pton',)

    First off, thanks, love this sdk. In python google app engine, I continue to get the following error message with the login button, do we need to change the port number somewhere in the requests module?

    Google App Engine RuntimeError: error('illegal IP address string passed to inet_pton',)

    google-app-engine 
    opened by chrisrote 10
  • add get_all_connections method

    add get_all_connections method

    This method will iterate over all pages yielded by a get_connections call and yield the individual items.

    I create the new request as a new get_connection call, which I think is nicer than doing a raw request. Line 135 is a bit hacky, but I couldn't think of another easy way to get all arguments except for the access token.

    It now yields individual items rather than pages, which I think is more useful for most users, but this can be easily changed.

    See https://github.com/mobolic/facebook-sdk/issues/85

    needs-tests needs-documentation 
    opened by vanatteveldt 9
  • Added raw_request to request things like pagination and linked objects

    Added raw_request to request things like pagination and linked objects

    Also made the request for FQL and Graph more DRY. This should behave almost exactly the same as before, but with added request_raw method and less duplicated code.

    Review on Reviewable

    opened by RickyCook 9
  • Python 3.X compatibility

    Python 3.X compatibility

    I made the library compatible with 3.X, though there are probably still string encoding bugs because of the way Python 3 handles strings. Importantly, the library should still behave identically on python 2.X.

    enhancement 
    opened by ogier 9
  • I am getting this issue while creating post request

    I am getting this issue while creating post request

    Traceback (most recent call last): File "facebooktoken.py", line 6, in post = graph.get_object(id='education-experience-id') File "/usr/local/lib/python2.7/dist-packages/facebook/init.py", line 105, in get_object return self.request(self.version + "/" + id, args) File "/usr/local/lib/python2.7/dist-packages/facebook/init.py", line 272, in request raise GraphAPIError(result) facebook.GraphAPIError: (#803) Some of the aliases you requested do not exist: education-experience-id

    opened by clock21am 8
  • softened version check and set default version to 13.0

    softened version check and set default version to 13.0

    This change removes the check against VALID_API_VERSIONS, which always required changes to the library (eg #496, #502), when a new Graph API version has been released. Instead only the pattern check is executed.

    I've also changed the default API version to the latest Graph API version v13.0.

    opened by th3hamm0r 1
  • How can i put love react on post facebook API

    How can i put love react on post facebook API

    ### thats my code but put only like no (love or wow or care)

    graph = 'access token'
    fb = facebook.GraphAPI(access_token = graph, version='3.0') 
    fb.put_like("my page id _my post id") 
    time.sleep(1)
    
    opened by siefmarzok 0
  • Update import SQLAlchemy

    Update import SQLAlchemy

    The "flask.ext" style of naming/importing modules has been deprecated for a number of years now. You should use from flask_sqlalchemy import SQLAlchemy instead.

    opened by apurvsibal 0
  • JSONDecodeError raised when trying to use put_object method

    JSONDecodeError raised when trying to use put_object method

    Version of the SDK being used

    3.0.0

    Expected Behavior

    Return a JSON object or string(if unable to decode)

    Actual Behavior

    JSONDecodeError Exception was raised

    Steps to Reproduce

    Facebook returns Sorry, this content isn't available right now which cannot be parsed to a JSON object

    opened by sirrobot01 1
Releases(v3.0.0)
Graviti-python-sdk - Graviti Data Platform Python SDK

Graviti Python SDK Graviti Python SDK is a python library to access Graviti Data

Graviti 13 Dec 15, 2022
Python SDK for Facebook's Graph API

Facebook Python SDK This client library is designed to support the Facebook Graph API and the official Facebook JavaScript SDK, which is the canonical

Mobolic 2.7k Jan 7, 2023
The Official Dropbox API V2 SDK for Python

The offical Dropbox SDK for Python. Documentation can be found on Read The Docs. Installation Create an app via the Developer Console. Install via pip

Dropbox 828 Jan 5, 2023
Unofficial Medium Python Flask API and SDK

PyMedium - Unofficial Medium API PyMedium is an unofficial Medium API written in python flask. It provides developers to access to user, post list and

Engine Bai 157 Nov 11, 2022
Python SDK for the Buycoins API.

This library provides easy access to the Buycoins API using the Python programming language. It provides all the feature of the API so that you don't need to interact with the API directly. This library can be used with Python 3.6+

Musa Rasheed 48 May 4, 2022
qualysclient - a python SDK for interacting with the Qualys API

qualysclient - a python SDK for interacting with the Qualys API

null 5 Oct 28, 2022
A Python 2.7/3.x module for Amcrest Cameras using the SDK HTTP API.

A Python 2.7/3.x module for Amcrest Cameras using the SDK HTTP API. Amcrest and Dahua devices share similar firmwares. Dahua Cameras and NVRs also work with this module.

Marcelo Moreira de Mello 176 Dec 21, 2022
An Python SDK for QQ based on mirai-api-http v2.

Argon 一个基于 graia-broadcast 和 mirai-api-http v2 的 Python SDK。 本项目适用于 mirai-api-http 2.0 以上版本。 目前仍处于开发阶段,内部接口可能会有较大的变化。 The Stasis / 停滞 为维持 GraiaProject

BlueGlassBlock 1 Oct 29, 2021
An elegant mirai-api-http v2 Python SDK.

Ariadne 一个适用于 mirai-api-http v2 的 Python SDK。 本项目适用于 mirai-api-http 2.0 以上版本。 目前仍处于开发阶段,内部接口可能会有较大的变化。 安装 poetry add graia-ariadne 或 pip install graia

Graia Project 259 Jan 2, 2023
Python SDK for accessing the Hanko Authentication API

Hanko Authentication SDK for Python This package is maintained by Hanko. Contents Introduction Documentation Installation Usage Prerequisites Create a

Hanko.io 3 Mar 8, 2022
Balsam Python client API & SDK

balsam No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) This Python package is automatically

Darren Govoni 1 Oct 22, 2021
Python SDK for interacting with the Frame.io API.

python-frameio-client Frame.io Frame.io is a cloud-based collaboration hub that allows video professionals to share files, comment on clips real-time,

Frame.io 37 Dec 21, 2022
DongTai API SDK For Python

DongTai-SDK-Python Quick start You need a config file config.json { "DongTai":{ "token":"your token", "url":"http://127.0.0.1:90"

huoxian 50 Nov 24, 2022
Python 3 SDK/Wrapper for Huobi Crypto Exchange Api

This packages intents to be an idiomatic PythonApi wrapper for https://www.huobi.com/ Huobi Api Doc: https://huobiapi.github.io/docs Showcase TODO Con

null 3 Jul 28, 2022
A wrapper for aqquiring Choice Coin directly through a Python Terminal. Leverages the TinyMan Python-SDK.

CHOICE_TinyMan_Wrapper A wrapper that allows users to acquire Choice Coin directly through their Terminal using ALGO and various Algorand Standard Ass

Choice Coin 16 Sep 24, 2022
AWS SDK for Python

Boto3 - The AWS SDK for Python Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to wri

the boto project 7.8k Jan 8, 2023
Box SDK for Python

Box Python SDK Installing Getting Started Authorization Server-to-Server Auth with JWT Traditional 3-legged OAuth2 Other Auth Options Usage Documentat

Box 371 Dec 29, 2022
Evernote SDK for Python

Evernote SDK for Python Evernote API version 1.28 This SDK is intended for use with Python 2.X For Evernote's beta Python 3 SDK see https://github.com

Evernote 612 Dec 30, 2022
Python SDK for IEX Cloud

iexfinance Python SDK for IEX Cloud. Architecture mirrors that of the IEX Cloud API (and its documentation). An easy-to-use toolkit to obtain data for

Addison Lynch 640 Jan 7, 2023