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)
Bot Realm of the Mad God Exalt (ROTMG). (Auto_nexus, Auto_HP, Auto_Loot)

Bot_ROTMG Bot Realm of the Mad God Exalt (ROTMG). (Auto_nexus, Auto_HP, Auto_Loot) *Este projeto visa apenas o aprendizado, quem faz mal uso é o único

Guilherme Silva Uchoa 1 Oct 30, 2021
A minimalistic, modern Discord bot for roles and polls using dropdowns

DropBot A minimalistic, modern Discord bot for roles and polls using dropdowns Made by ThatOneCalculator Technologies used Instructions Type /, and na

ModernBots 1 Jun 27, 2022
Collaboration with Microsoft, AWS, Google, and ETHZürich Analytics Club (2022 Datathon Project)

DATATHON_ Collaboration with Microsoft, AWS, Google, and ETHZürich Analytics Club (2022 Datathon Project) Datathon Original Challenge SAV DataDays Rei

esthi 34 Nov 10, 2022
Unofficial Discord Rich Presence for HackTheBox platform

HTBRichPresence Unofficial Discord Rich Presence for HackTheBox platform The project is under lazy development. How to run Install requirements: // I'

Antonio 4 Apr 19, 2022
A simple Python script using Telethon to log all (or some) messages a user or bot account can see on Telegram.

telegram-logger A simple Python script using Telethon to log all (or some) messages a user or bot account can see on Telegram. Requirements Python 3.6

Richard 13 Oct 06, 2022
Bot made by BLACKSTORM[BM] Contact Us - t.me/BLACKSTORM18

ᴡʜᴀᴛ ɪs ᴊᴀʀᴠɪs sᴇᴄᴜʀɪᴛʏ ʙᴏᴛ ᴊᴀʀᴠɪs ʙᴏᴛ ɪs ᴛᴇʟᴇɢʀᴀᴍ ɢʀᴏᴜᴘ ᴍᴀɴᴀɢᴇʀ ʙᴏᴛ ᴡɪᴛʜ ᴍᴀɴʏ ғᴇᴀᴛᴜʀᴇs. ᴛʜɪs ʙᴏᴛ ʜᴇʟᴘs ʏᴏᴜ ᴛᴏ ᴍᴀɴᴀɢᴇ ʏᴏᴜʀ ɢʀᴏᴜᴘs ᴇᴀsɪʟʏ. ᴏʀɪɢɪɴᴀʟʟʏ ᴀ

1 Dec 11, 2021
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 07, 2023
Python wrapper for Stanford CoreNLP.

stanfordcorenlp stanfordcorenlp is a Python wrapper for Stanford CoreNLP. It provides a simple API for text processing tasks such as Tokenization, Par

884 Dec 25, 2022
Simple script to extract useful informations from the combo BloodHound + Neo4j

bloodhound-quickwin Simple script to extract useful informations from the combo BloodHound + Neo4j. Can help to choose a target. Prerequisites python3

140 Dec 21, 2022
Implement backup and recovery with AWS Backup across your AWS Organizations using a CI/CD pipeline (AWS CodePipeline).

Backup and Recovery with AWS Backup This repository provides you with a management and deployment solution for implementing Backup and Recovery with A

AWS Samples 8 Nov 22, 2022
An advanced telegram movie information finder bot

An advanced telegram movie information finder bot

Fayas Noushad 22 Aug 23, 2022
A very simple Salesforce.com REST API client for Python

Simple Salesforce Simple Salesforce is a basic Salesforce.com REST API client built for Python 3.5, 3.6, 3.7 and 3.8. The goal is to provide a very lo

simple salesforce 1.4k Dec 29, 2022
Semplice pagina di informazione per sapere se e quando è uscito Joypad, il podcast a tema videoludico di Matteo Bordone (Corri!), Francesco Fossetti (Salta!) e Alessandro Zampini (Spara! per finta).

È uscito Joypad? Semplice pagina di informazione per sapere se e quando è uscito Joypad, il podcast a tema videoludico di Matteo Bordone (Corri!), Fra

Paolo Donadeo 32 Jan 02, 2023
Braintree Python library

Braintree Python library The Braintree Python library provides integration access to the Braintree Gateway. TLS 1.2 required The Payment Card Industry

Braintree 230 Dec 18, 2022
A simple Telegram bot, written in Python, that you can use to shill (i.e. send messages) your token, or whatever, to channels.

Telegram Shill Bot Ever wanted a Shill Bot but wankers keep scamming for one OR wanted to charge you an arm and a leg? This is a simple bot written in

53 Nov 25, 2022
My homeserver setup. Everything managed securely using Portainer.

homeserver-traefik-portainer Features: access all services with free TLS from letsencrypt using your own domain running a side project is super simple

Tomasz Wójcik 44 Jan 03, 2023
A template that everyone can use for the start of their discord bot

Python Discord Bot Template This repository is a template that everyone can use for the start of their discord bot. When I first started creating my d

2 Nov 01, 2021
It connects to Telegram's API. It generates JSON files containing channel's data, including channel's information and posts.

It connects to Telegram's API. It generates JSON files containing channel's data, including channel's information and posts. You can search for a specific channel, or a set of channels provided in a

Esteban Ponce de Leon 75 Jan 02, 2023
A listener for RF >= 4.0 that prints a Stack Trace to console to faster find the code section where the failure appears.

robotframework-stacktrace A listener for RF = 4.0 that prints a Stack Trace to console to faster find the code section where the failure appears. Ins

marketsquare 16 Nov 24, 2022
微信支付接口V3版python库

wechatpayv3 介绍 微信支付接口V3版python库。 适用对象 wechatpayv3支持微信支付直连商户,接口说明详见 官网。 特性 平台证书自动更新,无需开发者关注平台证书有效性,无需手动下载更新; 支持本地缓存平台证书,初始化时指定平台证书保存目录即可。 适配进度 微信支付V3版A

chen gang 258 Jan 06, 2023