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)
A website application running in Google app engine, deliver rss news to your kindle. generate mobi using python, multilanguages supported.

Readme of english version refers to Readme_EN.md 简介 这是一个运行在Google App Engine(GAE)上的Kindle个人推送服务应用,生成排版精美的杂志模式mobi/epub格式自动每天推送至您的Kindle或其他邮箱。 此应用目前的主要

2.6k Jan 06, 2023
A python package for fetching informations from GitHub API

Py-GitHub A python package for fetching informations from GitHub API Made with Python3 (C) @FayasNoushad Copyright permission under MIT License Licens

Fayas Noushad 6 Nov 28, 2021
A Telegram AntiChannel bot to ban users who using channel to send message in group

Anti-Channel-bot A Telegram AntiChannel bot to ban users who using channel to send message in group. BOT LINK: Features: Automatic ban Whitelist Unban

Jigar varma 36 Oct 21, 2022
An open-source Discord bot that alerts your server when it's Funky Monkey Friday!

Funky-Monkey-Friday-Bot An open-source Discord bot that alerts your server when it's Funky Monkey Friday! Add it to your server here! https://discord.

Cole Swinford 0 Nov 10, 2022
A Python Module That Uses ANN To Predict A Stocks Price And Also Provides Accurate Technical Analysis With Many High Potential Implementations!

Stox ⚡ A Python Module For The Stock Market ⚡ A Module to predict the "close price" for the next day and give "technical analysis". It uses a Neural N

Dopevog 31 Dec 16, 2022
Want to play What Would Rather on your Server? Invite the bot now!😏

What is this Bot? 👀 What You Would Rather? is a Guessing game where you guess one thing. Long Description short Take this example: You typed r!rather

丂ㄚ么乙ツ 2 Nov 17, 2021
Telegram Bot Repo Capable of fetching the following Info via Anilist API inspired from AniFluid and Nepgear

Telegram Bot Repo Capable of fetching the following Info via Anilist API inspired from AniFluid and Nepgear Anime Airing Manga Character Scheduled Top

Rikka-Chan 2 Apr 01, 2022
A simple Python API wrapper for Cloudflare Stream's API.

python-cloudflare-stream A basic Python API wrapper for working with Cloudflare Stream. Arbington.com started off using Cloudflare Stream. We used the

Arbington 3 Sep 08, 2022
Wakatime Response In javascript and python

Project Title Wakatime Response In javascript and python Description just for refrence Getting Started Dependencies For Python: requests json For Java

Gjenius20 1 Dec 31, 2021
Pythonic and easy iCalendar library (rfc5545)

ics.py 0.8.0-dev : iCalendar for Humans Original repository (GitHub) - Bugtracker and issues (GitHub) - PyPi package (ics) - Documentation (Read The D

ics.py 513 Jan 02, 2023
Retrieves GitHub Stats via `git_api` and flask.

GitHub User Search Created using Python3 and git_api, coded by JBYT27. About This is a project I decided to make for Kajam, but I decided to choose a

an aspirin 4 May 11, 2022
API Wrapper in Python for WeebyAPI

API Wrapper in Python for WeebyAPI

ashish 3 Feb 28, 2022
(unofficial) Googletrans: Free and Unlimited Google translate API for Python. Translates totally free of charge.

Googletrans Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make

Suhun Han 3.2k Jan 04, 2023
OpenQuake's Engine for Seismic Hazard and Risk Analysis

OpenQuake Engine The OpenQuake Engine is an open source application that allows users to compute seismic hazard and seismic risk of earthquakes on a g

Global Earthquake Model 281 Dec 21, 2022
Facebook open graph api implementation using the Django web framework in python

Django Facebook by Thierry Schellenbach (mellowmorning.com) Status Django and Facebook are both rapidly changing at the moment. Meanwhile, I'm caught

Thierry Schellenbach 1.4k Dec 29, 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
The best discord.py template with a changeable prefix

Discord.py Bot Template By noma4321#0035 With A Custom Prefix To Every Guild Function Features Has a custom prefix that is changeable for every guild

Noma4321 5 Nov 24, 2022
Its Is A Telegram Maths Basic Calculator Bot

Its Is A Telegram Maths Basic Calculator Bot

ANKIT KUMAR 1 Dec 26, 2021
Bot facebook

botfb Bot facebook Login via cookies cara install $pkg update && pkg upgrade $pkg install git python $git clone https://github.com/Ainx-BOT/botfb $cd

Fahmi Dev 12 Dec 18, 2022
Telegram bot with various Sticker Tools

Sticker Tools Bot @Sticker_Tools_Bot A star ⭐ from you means a lot to us! Telegram bot with various Sticker Tools Usage Deploy to Heroku Tap on above

Stark Bots 20 Dec 08, 2022