diff --git a/README.md b/README.md deleted file mode 100644 index 479976a..0000000 --- a/README.md +++ /dev/null @@ -1,172 +0,0 @@ -Twython -======= - -[![Build Status](https://travis-ci.org/ryanmcgrath/twython.png?branch=master)](https://travis-ci.org/ryanmcgrath/twython) [![Downloads](https://pypip.in/d/twython/badge.png)](https://crate.io/packages/twython/) [![Coverage Status](https://coveralls.io/repos/ryanmcgrath/twython/badge.png?branch=master)](https://coveralls.io/r/ryanmcgrath/twython?branch=master) - -```Twython``` is the premier Python library providing an easy (and up-to-date) way to access Twitter data. Actively maintained and featuring support for Python 2.6+ and Python 3. It's been battle tested by companies, educational institutions and individuals alike. Try it today! - -Features --------- - -- Query data for: - - User information - - Twitter lists - - Timelines - - Direct Messages - - and anything found in [the docs](https://dev.twitter.com/docs/api/1.1) -- Image Uploading: - - Update user status with an image - - Change user avatar - - Change user background image - - Change user banner image -- OAuth 2 Application Only (read-only) Support -- Support for Twitter's Streaming API -- Seamless Python 3 support! - -Installation ------------- - -Install Twython via [pip](http://www.pip-installer.org/) - - $ pip install twython - -or, with [easy_install]( https://dev.twitter.com/docs/api/1.1/get/search/tweets says it takes "q" and "result_type" amongst other arguments - -```python -twitter.search(q='twitter') -twitter.search(q='twitter', result_type='popular') -``` - -Advanced Usage --------------- - -- [Advanced Twython Usage](http://google.com) -- [Streaming with Twython](http://google.com) - -Notes ------ -* Twython 3.0.0 has been injected with 1000mgs of pure awesomeness! OAuth 2 application authentication is now supported. And a *whole lot* more! See the [CHANGELOG](https://github.com/ryanmcgrath/twython/blob/master/HISTORY.rst#300-2013-xx-xx) for more details! - -Questions, Comments, etc? -------------------------- -My hope is that Twython is so simple that you'd never *have* to ask any questions, but if you feel the need to contact me for this (or other) reasons, you can hit me up at ryan@venodesigns.net. - -Or if I'm to busy to answer, feel free to ping mikeh@ydekproductions.com as well. - -Follow us on Twitter: -* **[@ryanmcgrath](http://twitter.com/ryanmcgrath)** -* **[@mikehelmick](http://twitter.com/mikehelmick)** - -Want to help? -------------- -Twython is useful, but ultimately only as useful as the people using it (say that ten times fast!). If you'd like to help, write example code, contribute patches, document things on the wiki, tweet about it. Your help is always appreciated! diff --git a/README.rst b/README.rst index 1b1cc34..61cb6f9 100644 --- a/README.rst +++ b/README.rst @@ -32,22 +32,33 @@ Features Installation ------------ -Install Twython via `pip `_:: +Install Twython via `pip `_ + +.. code-block:: bash $ pip install twython -or, with `easy_install `_:: +or, with `easy_install `_ + +.. code-block:: bash $ easy_install twython But, hey... `that's up to you `_. -Or, if you want the code that is currently on GitHub:: +Or, if you want the code that is currently on GitHub + +.. code-block:: bash git clone git://github.com/ryanmcgrath/twython.git cd twython python setup.py install +Documentation +------------- + +Documentation is available at https://twython.readthedocs.org/en/latest/ + Starting Out ------------ @@ -57,7 +68,9 @@ After you register, grab your applications ``Consumer Key`` and ``Consumer Secre The most common type of authentication is Twitter user authentication using OAuth 1. If you're a web app planning to have users sign up with their Twitter account and interact with their timelines, updating their status, and stuff like that this **is** the authentication for you! -First, you'll want to import Twython:: +First, you'll want to import Twython + +.. code-block:: python from twython import Twython @@ -69,28 +82,50 @@ Obtain Authorization URL Now, you'll want to create a Twython instance with your ``Consumer Key`` and ``Consumer Secret`` -:: + Only pass *callback_url* to *get_authentication_tokens* if your application is a Web Application + + Desktop and Mobile Applications **do not** require a callback_url + +.. code-block:: python APP_KEY = 'YOUR_APP_KEY' APP_SECET = 'YOUR_APP_SECRET' twitter = Twython(APP_KEY, APP_SECRET) + auth = twitter.get_authentication_tokens(callback_url='http://mysite.com/callback') +From the ``auth`` variable, save the ``oauth_token`` and ``oauth_token_secret`` for later use (these are not the final auth tokens). In Django or other web frameworks, you might want to store it to a session variable + +.. code-block:: python + + OAUTH_TOKEN = auth['oauth_token'] + OAUTH_TOKEN_SECRET = auth['oauth_token_secret'] + +Send the user to the authentication url, you can obtain it by accessing + +.. code-block:: python + + auth['auth_url'] + Handling the Callback ^^^^^^^^^^^^^^^^^^^^^ + If your application is a Desktop or Mobile Application *oauth_verifier* will be the PIN code + After they authorize your application to access some of their account details, they'll be redirected to the callback url you specified in ``get_autentication_tokens`` -You'll want to extract the ``oauth_token`` and ``oauth_verifier`` from the url. +You'll want to extract the ``oauth_verifier`` from the url. Django example: -:: - OAUTH_TOKEN = request.GET['oauth_token'] +.. code-block:: python + oauth_verifier = request.GET['oauth_verifier'] -Now that you have the ``oauth_token`` and ``oauth_verifier`` stored to variables, you'll want to create a new instance of Twython and grab the final user tokens:: +Now that you have the ``oauth_verifier`` stored to a variable, you'll want to create a new instance of Twython and grab the final user tokens + +.. code-block:: python twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) @@ -102,7 +137,7 @@ Once you have the final user tokens, store them in a database for later use!:: OAUTH_TOKEN = final_step['oauth_token'] OAUTH_TOKEN_SECERT = final_step['oauth_token_secret'] -For OAuth 2 (Application Only, read-only) authentication, see `our documentation `_ +For OAuth 2 (Application Only, read-only) authentication, see `our documentation `_ Dynamic Function Arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -114,7 +149,9 @@ Basic Usage **Function definitions (i.e. get_home_timeline()) can be found by reading over twython/endpoints.py** -Create a Twython instance with your application keys and the users OAuth tokens:: +Create a Twython instance with your application keys and the users OAuth tokens + +.. code-block:: python from twython import Twython twitter = Twython(APP_KEY, APP_SECRET @@ -125,18 +162,18 @@ Authenticated Users Home Timeline Documentation: https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline -:: +.. code-block:: python twitter.get_home_timeline() Updating Status ~~~~~~~~~~~~~~~ -This method makes use of dynamic arguments, `read more about them `_ +This method makes use of dynamic arguments, `read more about them `_ Documentation: https://dev.twitter.com/docs/api/1/post/statuses/update -:: +.. code-block:: python twitter.update_status(status='See how easy using Twython is!') @@ -145,7 +182,7 @@ Searching https://dev.twitter.com/docs/api/1.1/get/search/tweets says it takes "q" and "result_type" amongst other arguments -:: +.. code-block:: python twitter.search(q='twitter') twitter.search(q='twitter', result_type='popular') @@ -153,8 +190,8 @@ Searching Advanced Usage -------------- -- `Advanced Twython Usage `_ -- `Streaming with Twython `_ +- `Advanced Twython Usage `_ +- `Streaming with Twython `_ Notes diff --git a/docs/usage/starting_out.rst b/docs/usage/starting_out.rst index 0525ac0..076e9fa 100644 --- a/docs/usage/starting_out.rst +++ b/docs/usage/starting_out.rst @@ -44,6 +44,10 @@ Now, you'll want to create a Twython instance with your ``Consumer Key`` and ``C Obtain Authorization URL ^^^^^^^^^^^^^^^^^^^^^^^^ +.. note:: Only pass *callback_url* to *get_authentication_tokens* if your application is a Web Application + + Desktop and Mobile Applications **do not** require a callback_url + .. code-block:: python APP_KEY = 'YOUR_APP_KEY' @@ -52,10 +56,11 @@ Obtain Authorization URL twitter = Twython(APP_KEY, APP_SECRET) auth = twitter.get_authentication_tokens(callback_url='http://mysite.com/callback') -From the ``auth`` variable, save the ``oauth_token_secret`` for later use. In Django or other web frameworks, you might want to store it to a session variable +From the ``auth`` variable, save the ``oauth_token_secret`` for later use (these are not the final auth tokens). In Django or other web frameworks, you might want to store it to a session variable .. code-block:: python + OAUTH_TOKEN = auth['oauth_token'] OAUTH_TOKEN_SECRET = auth['oauth_token_secret'] Send the user to the authentication url, you can obtain it by accessing @@ -67,18 +72,18 @@ Send the user to the authentication url, you can obtain it by accessing Handling the Callback ^^^^^^^^^^^^^^^^^^^^^ +.. note:: If your application is a Desktop or Mobile Application *oauth_verifier* will be the PIN code + After they authorize your application to access some of their account details, they'll be redirected to the callback url you specified in ``get_autentication_tokens`` -You'll want to extract the ``oauth_token`` and ``oauth_verifier`` from the url. +You'll want to extract the ``oauth_verifier`` from the url. Django example: .. code-block:: python - - OAUTH_TOKEN = request.GET['oauth_token'] oauth_verifier = request.GET['oauth_verifier'] -Now that you have the ``oauth_token`` and ``oauth_verifier`` stored to variables, you'll want to create a new instance of Twython and grab the final user tokens +Now that you have the ``oauth_verifier`` stored to a variable, you'll want to create a new instance of Twython and grab the final user tokens .. code-block:: python diff --git a/twython/api.py b/twython/api.py index 52014e0..a133590 100644 --- a/twython/api.py +++ b/twython/api.py @@ -251,7 +251,6 @@ class Twython(EndpointsMixin, object): if self.oauth_version != 1: raise TwythonError('This method can only be called when your OAuth version is 1.0.') - callback_url = callback_url or self.callback_url request_args = {} if callback_url: request_args['oauth_callback'] = callback_url