{ "info": { "author": "Akgnah", "author_email": "1024@setq.me", "bugtrack_url": null, "classifiers": [], "description": "fanfou-py: a python oauth client for fanfou\n===========================================\n\n.. image:: https://img.shields.io/travis/akgnah/fanfou-py/master.svg\n :target: https://travis-ci.org/akgnah/fanfou-py\n\n.. image:: https://img.shields.io/pypi/v/fanfou.svg\n :target: https://pypi.python.org/pypi/fanfou\n\n.. image:: https://img.shields.io/pypi/l/fanfou.svg\n :target: https://pypi.python.org/pypi/fanfou\n\n.. image:: https://img.shields.io/badge/code_style-pep8-orange.svg\n :target: https://www.python.org/dev/peps/pep-0008\n\nInstallation\n------------\n\n.. code-block:: bash\n\n $ sudo pip install fanfou\n\nUsage\n-----\n\n.. code-block:: python\n\n >>> import fanfou\n\n\nStep 1: Authorize\n^^^^^^^^^^^^^^^^^^\n\nThe module provides several ways to authorize, see more details on `Fanfou API OAuth `_.\n\nWay 1:\n\"\"\"\"\"\"\n\n.. code-block:: python\n\n >>> consumer = {'key': 'your key', 'secret': 'your secret'}\n >>> client = fanfou.OAuth(consumer) # (1)(2)\n >>> request_token = client.request_token()\n >>> print(client.authorize_url) # browse the url to authorize\n >>> access_token = client.access_token() # done\n\n(1). The default callback is '`http://localhost:8080`'.\n\n(2). The default authorize_url is '`m.fanfou.com/`...', you can pass auth_host='fanfou.com' to change it.\n\nMaybe you handling the callback elsewhere, create a new client and get access_token, like that:\n\n.. code-block:: python\n\n >>> client = fanfou.OAuth(consumer, request_token)\n >>> access_token = client.access_token() # done\n >>> # or\n >>> client = fanfou.OAuth(consumer)\n >>> access_token = client.access_token(request_token) # done\n\nWay 2:\n\"\"\"\"\"\"\n\n.. code-block:: python\n\n >>> consumer = {'key': 'your key', 'secret': 'your secret'}\n >>> client = fanfou.OAuth(consumer, callback='oob')\n >>> request_token = client.request_token()\n >>> print(client.authorize_url) # browse the url and copy verifier_code\n >>> verifier_code = 'your verifier_code'\n >>> access_token = client.access_token(oauth_verifier=verifier_code) # done\n\nYou can also create a new client and get access_token, like the way 1 above.\n\nWay 3:\n\"\"\"\"\"\"\n\n.. code-block:: python\n\n >>> consumer = {'key': 'your key', 'secret': 'your secret'}\n >>> access_token = {'key': 'your key', 'secret': 'your secret'} # access_token is what you saved before\n >>> client = fanfou.OAuth(consumer, access_token) # done\n\nWay 4:\n\"\"\"\"\"\"\n\n.. code-block:: python\n\n >>> consumer = {'key': 'your key', 'secret': 'your secret'}\n >>> client = fanfou.XAuth(consumer, 'username', 'password') # done\n >>> access_token = client.access_token() # optional, if you want to save access_token\n\n\nUsing https:\n\"\"\"\"\"\"\"\"\"\"\"\"\n\nIn the lastest edition, you can using https like that:\n\n.. code-block:: python\n\n >>> consumer = {'key': 'your key', 'secret': 'your secret'}\n >>> client = fanfou.XAuth(consumer, 'username', 'password', fake_https=True)\n\nThe fake_https is available in all authorize ways.\n\n\nStep 2: Access API\n^^^^^^^^^^^^^^^^^^\n\nWe assume that you've got client on Step 1, now you have two styles to access API.\n\nStyle 1:\n\"\"\"\"\"\"\"\"\n\n.. code-block:: python\n\n >>> import json\n >>> \n >>> resp = client.request('/statuses/home_timeline', 'GET') # resp is a HTTPResponse instance\n >>> print(resp.code)\n >>> data = json.loads(resp.read()) # Python 3: data = json.loads(resp.read().decode('utf8'))\n >>> for item in data:\n >>> print(item['text'])\n >>> \n >>> body = {'status': 'update status test 1'}\n >>> resp = client.request('/statuses/update', 'POST', body)\n >>> print(resp.code)\n\n\nStyle 2:\n\"\"\"\"\"\"\"\"\n\n.. code-block:: python\n\n >>> import json\n >>> \n >>> fanfou.bound(client) # note the line\n >>> \n >>> body = {'page': 2, 'count': 20, 'mode': 'lite'}\n >>> resp = client.statuses.home_timeline()\n >>> data = json.loads(resp.read()) # Python 3: data = json.loads(resp.read().decode('utf8'))\n >>> for item in data:\n >>> print(item['text'])\n >>> \n >>> body = {'status': 'update status test 2'}\n >>> resp = client.statuses.update(body)\n >>> print(resp.code)\n\nIf you want to use style 2, you must **fanfou.bound(client)** before use. They have the same effect, just two different styles.\n\nJust put all you want to request args to a dict (above is body), and then access a API. If you want to upload a photo, please see **pack_image**.\nMore API details on `Fanfou API Apicategory `_.\n\n**What's new in 0.2.x**\n\n.. code-block:: python\n\n >>> fanfou.bound(client)\n >>> \n >>> resp = client.users.show()\n >>> data = resp.json() # equal: data = json.loads(resp.read().decode('utf8')) \n\nIn this update, you can get a Python object directly by using resp.json().\n\n\nMore details\n^^^^^^^^^^^^\n\npack_image(args, binary=None)\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nOn `/account/update_profile_image `_\nand `/photos/upload `_ you need to upload a image, **pack_image** can help you work easily.\n\n.. code-block:: python\n\n >>> # update profile image\n >>> args = {'image': 'test.jpg', 'mode': 'lite'}\n >>> body, headers = fanfou.pack_image(args)\n >>> resp = client.account.update_profile_image(body, headers)\n >>> # or, resp = client.request('/account/update_profile_image', 'POST', body, headers)\n >>> print(resp.code)\n >>> \n >>> # upload photo\n >>> args = {'photo': 'http://static.fanfou.com/img/fanfou.png', 'status': 'upload online photo'}\n >>> body, headers = fanfou.pack_image(args)\n >>> resp = client.photos.upload(body, headers)\n >>> print(resp.code)\n\nJust put the filename in the args, then pack_image it, and then you can access API. The image file can be local or network file, pack_image will auto read it.\n\nSometimes you want to provide binary bytes instead of filename when you're writing a webapp, because the data you get from the form is binary. (like `m.setq.me `_)\n\n.. code-block:: python\n\n >>> f = open('test.jpg')\n >>> args = {'photo': 'test.jpg', 'status': 'upload local photo'}\n >>> body, headers = fanfou.pack_image(args, binary=f.read()) # note the line\n >>> f.close()\n >>> resp = client.photos.upload(body, headers)\n >>> print(resp.code)\n\n\nprint_api('plain')\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nThe following code print all api_access_url that be allowed pass to client.request:\n\n.. code-block:: python\n\n >>> fanfou.print_api('plain')\n\nIf you type the line and watch the results carefully, you will find two api_access_url have *'/:id'*, they are:\n\n* `POST /favorites/destroy `_\n* `POST /favorites/create `_\n\nBecause these API need *id* on it's access_url, so we get id from body and replace :id, like that:\n\n.. code-block:: python\n\n >>> body = {'id': 'zFbiu4CsJrw'}\n >>> resp = client.request('/favorites/create/:id', 'POST', body)\n >>> print(resp.url)\n\nYou will see resp.url is http://api.fanfou.com/favorites/create/zFbiu4CsJrw.json (Forget to mention that '.json' will add to the access_url).\n\n\nprint_api('bound')\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\n.. code-block:: python\n\n >>> fanfou.print_api('bound')\n\nThe line like *fanfou.print_api('plain')* but it will print all available methods that like client.statuses.home_timeline.\n\nYour IDE (or editor) can autocomplete them after **fanfou.bound(client)**.\n\nauth classes\n\"\"\"\"\"\"\"\"\"\"\"\"\n\nThe __init__ method for auth classes is as follows:\n\nclass **OAuth** (oauth_consumer, oauth_token=None, callback=None, auth_host=None, https=False, fake_https=False)\n\nclass **XAuth** (oauth_consumer, username, password, https=False, fake_https=False)\n\nThanks\n------\n\nThank `Fanfou `_ and thank you for tolerating my poor English.\n\nIf you have any questions, I am here `@home2 `_.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/akgnah/fanfou-py", "keywords": "fanfou oauth", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "fanfou", "package_url": "https://pypi.org/project/fanfou/", "platform": "any", "project_url": "https://pypi.org/project/fanfou/", "project_urls": { "Homepage": "http://github.com/akgnah/fanfou-py" }, "release_url": "https://pypi.org/project/fanfou/0.2.6/", "requires_dist": [ "six" ], "requires_python": "", "summary": "OAuth of Fanfou", "version": "0.2.6" }, "last_serial": 3345407, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5f9ed7cab8a8e576708cdb658f18e158", "sha256": "789ff124539d50276e8e1b2c6d747bda4f4ba4cf6711ce2a9c09cab08a2205cc" }, "downloads": -1, "filename": "fanfou-0.1.0-py2-none-any.whl", "has_sig": false, "md5_digest": "5f9ed7cab8a8e576708cdb658f18e158", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 6386, "upload_time": "2016-09-04T06:48:06", "url": "https://files.pythonhosted.org/packages/13/91/5bab3c317be49bc1bed3fa4a8d17d0c7c6154988ee83bb8d6371d54dd615/fanfou-0.1.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f1db9cc26fd5f528634c24ab4b7a933e", "sha256": "3c6f1809fa79f642aabca3a9a41ee2512fd009a5f8b991489b1350555c4e1325" }, "downloads": -1, "filename": "fanfou-0.1.0-py2-none-any.zip", "has_sig": false, "md5_digest": "f1db9cc26fd5f528634c24ab4b7a933e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6337, "upload_time": "2016-09-04T06:48:42", "url": "https://files.pythonhosted.org/packages/07/20/687bf4f9e496f1e9e162517db8df15fd20a9d4afc9a9913696879821d72c/fanfou-0.1.0-py2-none-any.zip" }, { "comment_text": "", "digests": { "md5": "41b2aa11064dc61c3dada597add8fd87", "sha256": "79ae673df1bc46b6b00198e3e1761185c72b8f5667660fecc3681a072b41e8ad" }, "downloads": -1, "filename": "fanfou-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "41b2aa11064dc61c3dada597add8fd87", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 6356, "upload_time": "2016-09-04T06:49:10", "url": "https://files.pythonhosted.org/packages/7f/aa/c2e6408ba8852c983a48523e8f3b71026ec14bc5ed037a3d2ed06350f42c/fanfou-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e3af605107e53513fc8cadf82ef1ec94", "sha256": "37648130f370de3c0ce6c7197ccdd8036b238146e0d3b9d7cd2ecbda9ffc7549" }, "downloads": -1, "filename": "fanfou-0.1.0-py3-none-any.zip", "has_sig": false, "md5_digest": "e3af605107e53513fc8cadf82ef1ec94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6314, "upload_time": "2016-09-04T06:49:19", "url": "https://files.pythonhosted.org/packages/73/c5/9a345ed1336eec519c308d62927142a9efe1e856e171483ef65f426a9a34/fanfou-0.1.0-py3-none-any.zip" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "2e3b9abf458c36e6cf8e4507144d6c26", "sha256": "1bf9a4a9abdbb891240bea02dd4388b25b1ced1ccca2d5fc3cee8eec193f9883" }, "downloads": -1, "filename": "fanfou-0.2.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2e3b9abf458c36e6cf8e4507144d6c26", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10669, "upload_time": "2017-10-13T14:27:58", "url": "https://files.pythonhosted.org/packages/e5/ac/49b54dff384f98aafd41d43b1f01c2a1e28d32c080dd279ac6730aa9a155/fanfou-0.2.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5ab1703429d8affb313df1846d2ee63c", "sha256": "b0867c6502856f58e03c6b1cc19d494ecd83d6d45d64c3f7c813fbfaef0b1f6b" }, "downloads": -1, "filename": "fanfou-0.2.5.tar.gz", "has_sig": false, "md5_digest": "5ab1703429d8affb313df1846d2ee63c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7124, "upload_time": "2017-10-13T14:28:00", "url": "https://files.pythonhosted.org/packages/7a/d9/343ffd105c41a9a887c39e44a8d9ad5794cd080014734db1fc707a7d5b51/fanfou-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "a95ae509fa69b53b9afef81258901cb0", "sha256": "035bb28d919b20c190562583cb5b89f81f7f9cca6873b6ff55e83d9f83805890" }, "downloads": -1, "filename": "fanfou-0.2.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a95ae509fa69b53b9afef81258901cb0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10927, "upload_time": "2017-11-19T08:18:30", "url": "https://files.pythonhosted.org/packages/ea/fb/91f1aa616596aecc96fd871aadf643ebbedba6eed402acd0a4d7a031b8de/fanfou-0.2.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f83dcbe8c062efa84935903b5fb35b84", "sha256": "6e79ccaf6c4d283bfb6234f9f748f36f862339ec7208726966f5bca5a643a0e1" }, "downloads": -1, "filename": "fanfou-0.2.6.tar.gz", "has_sig": false, "md5_digest": "f83dcbe8c062efa84935903b5fb35b84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7343, "upload_time": "2017-11-19T08:18:32", "url": "https://files.pythonhosted.org/packages/4d/1f/34bd89d34d324129986f8ce42bf8bbddba8b0cd4249b213f9dcfb5656446/fanfou-0.2.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a95ae509fa69b53b9afef81258901cb0", "sha256": "035bb28d919b20c190562583cb5b89f81f7f9cca6873b6ff55e83d9f83805890" }, "downloads": -1, "filename": "fanfou-0.2.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a95ae509fa69b53b9afef81258901cb0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10927, "upload_time": "2017-11-19T08:18:30", "url": "https://files.pythonhosted.org/packages/ea/fb/91f1aa616596aecc96fd871aadf643ebbedba6eed402acd0a4d7a031b8de/fanfou-0.2.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f83dcbe8c062efa84935903b5fb35b84", "sha256": "6e79ccaf6c4d283bfb6234f9f748f36f862339ec7208726966f5bca5a643a0e1" }, "downloads": -1, "filename": "fanfou-0.2.6.tar.gz", "has_sig": false, "md5_digest": "f83dcbe8c062efa84935903b5fb35b84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7343, "upload_time": "2017-11-19T08:18:32", "url": "https://files.pythonhosted.org/packages/4d/1f/34bd89d34d324129986f8ce42bf8bbddba8b0cd4249b213f9dcfb5656446/fanfou-0.2.6.tar.gz" } ] }