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 fast and expressive Craigslist API wrapper

pycraigslist A fast and expressive Craigslist API wrapper. ⚠ As of September 2021, it is believed that Craigslist added a rate-limiter. It is advised

Ira Horecka 24 Dec 28, 2022
Easy to use API Wrapper for somerandomapi.ml.

Overview somerandomapi is an API Wrapper for some-random-api.ml Examples Asynchronous from somerandomapi import Animal

Myxi 1 Dec 31, 2021
Code release for "Cycle Self-Training for Domain Adaptation" (NeurIPS 2021)

CST Code release for "Cycle Self-Training for Domain Adaptation" (NeurIPS 2021) Prerequisites torch=1.7.0 torchvision qpsolvers numpy prettytable tqd

31 Jan 08, 2023
Randomly selects two teams based on who is in a voice channel on Discord

TeamPickerDiscordBot Randomly selects two teams based on who is in a voice channel on Discord What I Learned The ins and outs of Python as this was my

Brecken Enneking 2 Jan 27, 2022
Terraform module to ship CloudTrail logs stored in a S3 bucket into a Kinesis stream for further processing and real-time analysis.

AWS infrastructure to ship CloudTrail logs from S3 to Kinesis This repository contains a Terraform module to ship CloudTrail logs stored in a S3 bucke

Nexthink 8 Sep 20, 2022
This is a simple Python bot to identify sentiments in tweets

Twitter-Sentiment 👋 Hi There! 📱 This is a simple Python bot to identify sentiments in tweets 👨‍💻 This project was made for study, and pratice. You

Guilherme Silva 1 Oct 28, 2021
Python module and command line script client for http://urbandictionary.com

py-urbandict py-urbandict is a client for urbandictionary.com. Project page on github: https://github.com/novel/py-urbandict PyPI: https://pypi.org/pr

Roman Bogorodskiy 32 Oct 01, 2022
Telegram Bot to save Posts or Files that can be Accessed via Special Links

OKAERI-FILE Bot Telegram untuk menyimpan Posting atau File yang dapat Diakses melalui Link Khusus. Jika Anda memerlukan tambahan module lagi dalam rep

Wahyusaputra 5 Aug 04, 2022
Telegram bot for stream music or video on telegram

KYURA MUSIC Telegram bot for stream music or video on telegram, powered by PyTgCalls and Pyrogram Help Need Help me to translate this repo, click the

0 Dec 08, 2022
pyhakuna is a client to access the API of the time keeping service hakuna.ch.

pyhakuna pyhakuna is a client to access the API of the time keeping service hakuna.ch. The Hakuna API is – unfortunately – personal and currently does

Christian Mäder 1 Feb 15, 2022
Parse 11.000 free proxies!

Proxy Machine Description I did this project in order to boost views with the teleboost ✈️ in my Telegram channel. You can use it not only for boostin

VLDSLV 77 Jan 08, 2023
Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

3 Oct 25, 2022
Senditapp.com bot spammer, spam your friends

Sendit Spammer Python ⚠️ I am not responsible for how you use this tool. This tool is against "Sendit" ToS and shall not be used in a production envir

Glaukio 1 Dec 31, 2021
This is a okay that is okay that means none is okay

Owner: Masterolic 🇮🇳 CatUB A Powerful, Smart And Simple Userbot In Telethon. Credits This is A Remix Bot Of Many UserBot. DARKCOBRA FridayUserBot Ja

Masterolic 1 Nov 28, 2021
An open souce video/music streamer based on MPV and piped.

🎶 Harmony Music An easy way to stream videos or music from Youtube from the command line while regaining your privacy. 📖 Table Of Contents ❔ What's

Zingy Tomato 16 Nov 15, 2022
vk Bot because of which everyone will lag

VK-crash-bot open cmd and write: "pip install vk-api" To configure the bot, you need to open main.py and set the value to such variables as "token" an

NotQuki 0 Jun 05, 2022
Linkvertise-Bypass - Bypass Linkvertise advertisement

Linkvertise-Bypass Bypass Linkvertise advertisement 📕 instructions Copy And Pas

Flex Tools 4 Jun 10, 2022
Full-featured Python interface for the Slack API

This repository is archived and will not receive any updates It's time to say goodbye. I'm archiving Slacker. It's been getting harder to find time to

Oktay Sancak 1.6k Dec 13, 2022
A small bot to interact with the reddit API. Get top viewers and update the sidebar widget.

LiveStream_Reddit_Bot Get top twitch and facebook stream viewers for a game and update the sidebar widget and old reddit sidebar to show your communit

Tristan Wise 1 Nov 21, 2021
A client library for the REST API of DocuWare's DMS

docuware-client This is a client library for the REST API of DocuWare DMS. Since DocuWare's documentation regarding the REST API is very sparse (at th

Stefan Schönberger 1 Feb 23, 2022