|
| 1 | +=================== |
| 2 | +Facebook Python SDK |
| 3 | +=================== |
| 4 | + |
| 5 | +This client library is designed to support the `Facebook Graph API`_ and the |
| 6 | +official `Facebook JavaScript SDK`_, which is the canonical way to implement |
| 7 | +Facebook authentication. You can read more about the Graph API by accessing its |
| 8 | +`official documentation`_. |
| 9 | + |
| 10 | +.. _Facebook Graph API: https://developers.facebook.com/docs/reference/api/ |
| 11 | +.. _Facebook JavaScript SDK: https://developers.facebook.com/docs/reference/javascript/ |
| 12 | +.. _official documentation: https://developers.facebook.com/docs/reference/api/ |
| 13 | + |
| 14 | +Basic usage: |
| 15 | + |
| 16 | +:: |
| 17 | + |
| 18 | + graph = facebook.GraphAPI(oauth_access_token) |
| 19 | + profile = graph.get_object("me") |
| 20 | + friends = graph.get_connections("me", "friends") |
| 21 | + graph.put_object("me", "feed", message="I am writing on my wall!") |
| 22 | + |
| 23 | +Photo uploads: |
| 24 | + |
| 25 | +:: |
| 26 | + |
| 27 | + graph = facebook.GraphAPI(oauth_access_token) |
| 28 | + tags = json.dumps([{'x':50, 'y':50, tag_uid:12345}, {'x':10, 'y':60, tag_text:'a turtle'}]) |
| 29 | + graph.put_photo(open('img.jpg'), 'Look at this cool photo!', album_id_or_None, tags=tags) |
| 30 | + |
| 31 | +If you are using the module within a web application with the JavaScript SDK, |
| 32 | +you can also use the module to use Facebook for login, parsing the cookie set |
| 33 | +by the JavaScript SDK for logged in users. For example, in Google AppEngine, |
| 34 | +you could get the profile of the logged in user with: |
| 35 | + |
| 36 | +:: |
| 37 | + |
| 38 | + user = facebook.get_user_from_cookie(self.request.cookies, key, secret) |
| 39 | + if user: |
| 40 | + graph = facebook.GraphAPI(user["access_token"]) |
| 41 | + profile = graph.get_object("me") |
| 42 | + friends = graph.get_connections("me", "friends") |
| 43 | + |
| 44 | + |
| 45 | +You can see a full AppEngine example application in examples/appengine. |
| 46 | + |
| 47 | +Reporting Issues |
| 48 | +================ |
| 49 | + |
| 50 | +If you have bugs or other issues specifically pertaining to this library, file |
| 51 | +them `here`_. Bugs with the Graph API should be filed on `Facebook's |
| 52 | +bugtracker`_. |
| 53 | + |
| 54 | +.. _here: https://github.com/pythonforfacebook/facebook-sdk/issues |
| 55 | +.. _Facebook's bugtracker: https://developers.facebook.com/bugs/ |
0 commit comments