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)
Source code of BobuxAdmin bot from Bobux Bot Development server.

BobuxAdmin Source code of BobuxAdmin bot from Bobux Bot Development server. The bot is written with usage of disnake and SQLite database. Functionalit

Bobux Bot Developers 3 Dec 29, 2022
Powerful spammer bots for telegram made with python and telethon.

Powerful spammer bots for telegram made with python and telethon. We can deploy upto 70 bots at a time.

32 Dec 15, 2022
Discord Token Creator 🥵

Discord Token Creator 🥵

dropout 304 Jan 03, 2023
Step by Step Guide To Install Discord Py Master Branch on Replit

Guide to Install Discord Py Master Branch on Replit Step 1 Create an empty repl on replit Step 2 Add this Basic Code to the file main.py so as to chec

Pranav Saxena 7 Nov 18, 2022
Unfollows Users You're Following

Github-Unfollow-Bot Info It unfollows users you're following, it runs in the background so you can still do what you do without it bothering you. It's

ExT 4 Sep 03, 2022
Send embeds using your discord personal account

Welcome to Embed Sender 👋 Send embeds using your discord personal account Install pip install -r requirements.txt Usage Put your discord token in ./

SkydenFly 11 Sep 07, 2022
Simple Discord bot for snekbox (sandboxed Python code execution), self-host or use a global instance

snakeboxed Simple Discord bot for snekbox (sandboxed Python code execution), self-host or use a global instance

0 Jun 25, 2022
1 Feb 18, 2022
Get notifications in your Discord server of any software releases from Apple.

Apple Releases Get notifications in your Discord server of any software releases from Apple. Running To locally host your own instance, create a Disco

adam 17 Oct 22, 2022
A small repository with convenience functions for working with the Notion API.

Welcome! Within this respository are a few convenience functions to assist with the pulling and pushing of data from the Notion API.

10 Jul 09, 2022
A simple telegram bot that resolves video urls using yt-dlp

URL to Video Telegram Bot A simple telegram bot that resolves video urls using yt-dlp Copyright (C) 2021 Vítor Vasconcellos This program is free softw

Vítor 1 Nov 18, 2021
veez music bot is a telegram music bot project, allow you to play music on voice chat group telegram.

🎶 Veez Music Bot Music bot for playing music on telegram voice chat group. Requirements 📝 FFmpeg NodeJS nodesource.com Python 3.7+ PyTgCalls 🧪 Get

levina 143 Jun 19, 2022
Optimus Prime - A modular Telegram group management and drive clone bot running on Python with sqlalchemy database

Optimus Prime Bot . 🤖 A modular Telegram group management and drive clone bot r

9 Jun 01, 2022
Compulsory join Telegram Bot

mussjoin About Compulsory join Telegram Bot this Telegram Bot Application can be added users to Telegram Channel or Group compulsorily. in addition wh

Hamed Mohammadvand 4 Dec 03, 2021
Discord bot to display private leaderboards for Advent of Code.

Advent Of Code Discord Bot Discord bot for displaying Advent of Code private leardboards, as well as custom leaderboards where participants can set th

The Future Gadgets Lab 6 Nov 29, 2022
A surviv.io bot that helps you manage you clan in surviv.io!

Scooter-Surviv.io-Clan-Bot A Surviv.io Discord Bot This is a bot that helps manage your surviv.io clan! Read below for more!!. Features Lets you creat

cosmic|duck 1 Jan 03, 2022
Instagram - Instagram Account Reporting Tool

Instagram Instagram Account Reporting Tool Installation On Termux $ apt update $

Aryan 6 Nov 18, 2022
all-in-one wrapper for NASA API's

=========== About bowshock is an all-in-one wrapper for NASA API's. Here is a list of currently supported API's : NASA Earth API NASA APOD (Astronomy

Emir Ozer 85 Nov 09, 2022
Telegram bot for our internal organizers tasks

Welcome to ppm-telegram-bot 👋 Telegram Bot Platform integration for bot commands processing. We use it for our internal @piterpy-meetup needs, basica

PiterPy Meetup 10 Jul 28, 2022
Subtitle Translater

Subtitle Translater

OshadhaVimukthi 2 Nov 29, 2021