Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get information from facebook using python?

I've looked at a lot of questions and libs and didn't found exactly what I wanted. Here's the thing, I'm developing an application in python for a user to get all sorts of things from social networks accounts. I'm having trouble with facebook. I would like, if possible, a step-by-step tutorial on the code and libs to use to get a user's information, from posts to photos information (with the user's login information, and how to do it, because I've had a lot of problem with authentication).

Thank you

like image 674
Shadez Avatar asked Oct 11 '22 23:10

Shadez


1 Answers

I strongly encourage you to use Facebook's own APIs.

First of all, check out documentation on Facebook's Graph API https://developers.facebook.com/docs/reference/api/. If you are not familiar with JSON, DO read a tutorial on it (for instance http://secretgeek.net/json_3mins.asp).

Once you grasp the concepts, start using this API. For Python, there are at several alternatives:

  • facebook/python-sdk https://github.com/facebook/python-sdk
  • pyFaceGraph https://github.com/iplatform/pyFaceGraph/
  • It is also semitrivial to write a simple HTTP client that uses the graph API

I would suggest you to check out the Python libraries, try out the examples in their documentation and see if they are working and do the stuff you need.

Only as a last resort, would I write a scraper and try to extract data with screenscraping (it is much more painful and breaks more easily).

like image 148
jsalonen Avatar answered Oct 20 '22 11:10

jsalonen