{ "info": { "author": "Mike Helmick", "author_email": "me@michaelhelmick.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Communications :: Chat", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Requests-Facebook\n=================\n\n\n``Requests-Facebook`` is a Python library to help interface with `Facebook Graph API `_ using the awesome ``requests`` library by `@kennethreitz `_\n\nFeatures\n--------\n\n* Authenticating Users\n* Dyanmic Facebook methods\n - Read home feeds/user feeds\n - Post status updates\n - Delete items\n - Like items\n - And many more!!\n* Photo Uploading\n\n\nInstallation\n------------\n\nInstalling Requests-Facebook is simple: ::\n\n $ pip install requests-facebook\n\n\nUsage\n-----\n\nAuthorization URL\n~~~~~~~~~~~~~~~~~\n\n::\n\n f = FacebookAPI(client_id='*your app key*',\n client_secret='*your app secret*',\n redirect_uri='http://example.com/callback/')\n\nor\n\n::\n\n f = FacebookAPI('*your app key*', '*your app secret*', 'http://example.com/callback/')\n\n::\n\n auth_url = f.get_auth_url(scope=['publish_stream', 'user_photos', 'user_status'])\n \n print 'Connect with Facebook via: %s' % auth_url\n\nOnce you click \"Allow\" be sure that there is a URL set up to handle getting finalized access_token and possibly adding it to your database to access their information at a later date.\n\nHandling the Callback\n~~~~~~~~~~~~~~~~~~~~~\n::\n\n # Assume you are using the FacebookAPI object from the Authorization URL code\n\n # You'll need to obtain `code` from the url query string\n\n # In Django, you'd do something like\n # code = request.GET.get('code')\n\n access_token = f.get_access_token(code)\n \n final_access_token = access_token['access_token']\n \n # Save that token to the database for a later use?\n\n\nDynamic Facebook methods\n~~~~~~~~~~~~~~~~~~~~~~~~\nSay you have the url ``https://graph.facebook.com/me/friends``\nTo make a call via this library, you'd do GraphAPI.get('me/friends')\n\nYou just take everything in the url *AFTER* ``https://graph.facebook.com/``\n\nGetting some User information\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n::\n\n # Get the final tokens from the database or wherever you have them stored\n\n graph = GraphAPI(access_token)\n\n # Print out your information\n try:\n print graph.get('me')\n except FacebookClientError:\n print 'Failed! :('\n\n # Print out my information\n print graph.get('mikehimself')\n\n\nGetting your Home Feed\n~~~~~~~~~~~~~~~~~~~~~~\n::\n\n # Assume you are using the GraphAPI instance from the previous section\n home_feed = graph.get('me/home')\n print home_feed\n\nGetting a Profile Feed\n~~~~~~~~~~~~~~~~~~~~~~\n::\n\n # Assume you are using the GraphAPI instance from the previous section\n your_feed = graph.get('me/feed')\n print your_feed\n\n # Getting my profile feed\n my_feed = graph.get('mikehimself/feed')\n print my_feed\n\nCreating a Photo Album\n~~~~~~~~~~~~~~~~~~~~~~\n::\n\n # Assume you are using the GraphAPI instance from the previous section\n new_album = graph.post('me/albums', params={'name':'Test Album'})\n print new_album\n\nPosting a Photo\n~~~~~~~~~~~~~~~\n::\n\n # Assume you are using the GraphAPI instance from the previous section\n # Assume you are using the album you just created in the previous section\n\n # new_album = new_album var from the previous section\n album_id = new_album['id']\n\n photo = open('path/to/file/image.jpg', 'rb')\n\n # The file key that Facebook expects is 'source', so 'source' will be apart\n # of the params dict.\n\n # You can pass any object that has a read() function (like a StringIO object)\n # In case you wanted to resize it first or something!\n\n new_photo = graph.post('%s/photos' % album_id, params={'message':'My photo caption!', 'source': photo})\n\n print new_photo\n\n\nPosting an Edited Photo *(This example resizes a photo)*\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n::\n\n # Assume you are using the GraphAPI instance from the previous section\n # Assume you are using the album you just created in the previous sections\n\n # Like I said in the previous section, you can pass any object that has a\n # read() method\n\n # Assume you are working with a JPEG\n\n from PIL import Image\n from StringIO import StringIO\n\n photo = Image.open('/path/to/file/image.jpg')\n\n basewidth = 320\n wpercent = (basewidth / float(photo.size[0]))\n height = int((float(photo.size[1]) * float(wpercent)))\n photo = photo.resize((basewidth, height), Image.ANTIALIAS)\n\n image_io = StringIO.StringIO()\n photo.save(image_io, format='JPEG')\n \n image_io.seek(0)\n\n try:\n new_photo = graph.post('%s/photos' % album_id, params={'message':'My photo caption!', 'source': photo})\n except FacebookClientError, e:\n # Maybe the file was invalid?\n print e.message\n\n\nCatching errors **(In case you didn't catch it in the first example)**\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n::\n\n # Assume you are using the GraphAPI instance from the previous section\n\n try:\n graph.delete('me/feed')\n except FacebookClientError, e:\n print e.message\n print 'Something bad happened :('\n\n\nTODO\n----\nSupport for Facebook REST API\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/michaelhelmick/requests-facebook/zipball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/michaelhelmick/requests-facebook/", "keywords": "python facebook requests graph oauth oauth2 api", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "requests-facebook", "package_url": "https://pypi.org/project/requests-facebook/", "platform": "", "project_url": "https://pypi.org/project/requests-facebook/", "project_urls": { "Download": "https://github.com/michaelhelmick/requests-facebook/zipball/master", "Homepage": "https://github.com/michaelhelmick/requests-facebook/" }, "release_url": "https://pypi.org/project/requests-facebook/0.4.2/", "requires_dist": null, "requires_python": "", "summary": "A Python Library to interface with Facebook Graph API", "version": "0.4.2" }, "last_serial": 3391066, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "4eee6dd7909d271aac5495d1366a3f8e", "sha256": "17336d77f3fe394689abe82f29a668c73ea1c5f0380e425d50378529ce3dbc4f" }, "downloads": -1, "filename": "requests-facebook-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4eee6dd7909d271aac5495d1366a3f8e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4255, "upload_time": "2012-06-07T00:18:48", "url": "https://files.pythonhosted.org/packages/ba/a5/ff2caf5631680395434ffb213f0782763ad1f8ca1d5f25edb31a1b7147be/requests-facebook-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "87adf6f2908912298569f8496ae0c825", "sha256": "8ca2954206bab127e45404ab7cba3c716887fcf7723e3edfc73b99f76c17156f" }, "downloads": -1, "filename": "requests-facebook-0.1.1.tar.gz", "has_sig": false, "md5_digest": "87adf6f2908912298569f8496ae0c825", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4321, "upload_time": "2012-06-07T18:20:26", "url": "https://files.pythonhosted.org/packages/a8/b6/320650a562caceedf5c628344765f2290a6930d83cd95f9be4ac28b7d822/requests-facebook-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "9d91d8e7270eb8de993212d4bc9d8d49", "sha256": "eac1c6aeb2903f88811e38f11158bebd31f7c69021ea73f58b264e2ecb6fb619" }, "downloads": -1, "filename": "requests-facebook-0.2.0.tar.gz", "has_sig": false, "md5_digest": "9d91d8e7270eb8de993212d4bc9d8d49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5582, "upload_time": "2012-06-07T22:46:22", "url": "https://files.pythonhosted.org/packages/f8/d9/48765ae6e07f896a1e92aa54a247f7bd6db02b3db70f8d8c5f33c85c759c/requests-facebook-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "0accc66a298ed73b1483d08b560f8266", "sha256": "4ebd5c1de690e549cce87d4d33a6e2e8b912a98487815444a7db10075d8471c6" }, "downloads": -1, "filename": "requests-facebook-0.3.0.tar.gz", "has_sig": false, "md5_digest": "0accc66a298ed73b1483d08b560f8266", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5560, "upload_time": "2016-03-08T21:28:11", "url": "https://files.pythonhosted.org/packages/b8/09/2bf2f043d002e056c25332df6f69d522a8557985a147e689234b183adf47/requests-facebook-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "3a95b6dd25ce5c0ec51593c83d566291", "sha256": "f6fdee896aaa0319e759ff5a0b64aa3e228c0d6c92ca70f03866332e6fe8ff13" }, "downloads": -1, "filename": "requests-facebook-0.4.0.tar.gz", "has_sig": false, "md5_digest": "3a95b6dd25ce5c0ec51593c83d566291", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5600, "upload_time": "2016-06-27T16:19:00", "url": "https://files.pythonhosted.org/packages/fd/8a/b47e074ab4c8b06dfb63155af1fe1e3ac7a384c06352d98749eb9c9c124c/requests-facebook-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "95d07f5c61f99cd74933933cc91caf09", "sha256": "d062d960cc933397844a0d9651c5216d93ddc42b1eb97b7c4d1e9ce9ebe2a384" }, "downloads": -1, "filename": "requests-facebook-0.4.1.tar.gz", "has_sig": false, "md5_digest": "95d07f5c61f99cd74933933cc91caf09", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5618, "upload_time": "2017-04-10T16:24:30", "url": "https://files.pythonhosted.org/packages/78/e2/cab2875b4afca49c16e94eb65e627fdebe8e9868c7f24de2c02ebb9aa867/requests-facebook-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "9207e76a50479494d2f3ac4407d961bf", "sha256": "4af174b06afd9cb87758450f02df495975324f851114250e63309f7b24fc1cc9" }, "downloads": -1, "filename": "requests-facebook-0.4.2.tar.gz", "has_sig": false, "md5_digest": "9207e76a50479494d2f3ac4407d961bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5751, "upload_time": "2017-12-05T16:14:28", "url": "https://files.pythonhosted.org/packages/b1/b2/1cb4eb6db7da5f6a1e8eccee59a45a061057dffa30167d03e980f696ec4f/requests-facebook-0.4.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9207e76a50479494d2f3ac4407d961bf", "sha256": "4af174b06afd9cb87758450f02df495975324f851114250e63309f7b24fc1cc9" }, "downloads": -1, "filename": "requests-facebook-0.4.2.tar.gz", "has_sig": false, "md5_digest": "9207e76a50479494d2f3ac4407d961bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5751, "upload_time": "2017-12-05T16:14:28", "url": "https://files.pythonhosted.org/packages/b1/b2/1cb4eb6db7da5f6a1e8eccee59a45a061057dffa30167d03e980f696ec4f/requests-facebook-0.4.2.tar.gz" } ] }