From 8ea61af4fc30e83e4d239ed3911a600cbb438fa4 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Mon, 25 Jun 2012 05:08:16 +0900 Subject: [PATCH] Documentation showcasing proper importing; kinda sorta needed. --- README.md | 12 ++++++++++++ README.rst | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 20ae8b5..d19f34f 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Usage Authorization URL ```python +from twython import Twython + t = Twython(app_key=app_key, app_secret=app_secret, callback_url='http://google.com/') @@ -51,6 +53,8 @@ Be sure you have a URL set up to handle the callback after the user has allowed Handling the callback ```python +from twython import Twython + ''' oauth_token and oauth_token_secret come from the previous step if needed, store those in a session variable or something @@ -70,6 +74,8 @@ print auth_tokens Getting a user home timeline ```python +from twython import Twython + ''' oauth_token and oauth_token_secret are the final tokens produced from the `Handling the callback` step @@ -87,6 +93,8 @@ print t.getHomeTimeline() Get a user avatar url *(no authentication needed)* ```python +from twython import Twython + t = Twython() print t.getProfileImageUrl('ryanmcgrath', size='bigger') print t.getProfileImageUrl('mikehelmick') @@ -95,6 +103,8 @@ print t.getProfileImageUrl('mikehelmick') Search Twitter *(no authentication needed)* ```python +from twython import Twython + t = Twython() print t.search(q='python') ``` @@ -104,6 +114,8 @@ Streaming API streams.* ```python +from twython import Twython + def on_results(results): """A callback to handle passed results. Wheeee. """ diff --git a/README.rst b/README.rst index 2025567..100dc27 100644 --- a/README.rst +++ b/README.rst @@ -37,7 +37,8 @@ Usage Authorization URL ~~~~~~~~~~~~~~~~~ :: - + from twython import Twython + t = Twython(app_key=app_key, app_secret=app_secret, callback_url='http://google.com/') @@ -59,6 +60,7 @@ Handling the callback oauth_token and oauth_token_secret come from the previous step if needed, store those in a session variable or something ''' + from twython import Twython t = Twython(app_key=app_key, app_secret=app_secret, @@ -78,19 +80,22 @@ Getting a user home timeline oauth_token and oauth_token_secret are the final tokens produced from the `Handling the callback` step ''' - + from twython import Twython + t = Twython(app_key=app_key, app_secret=app_secret, oauth_token=oauth_token, oauth_token_secret=oauth_token_secret) - + # Returns an dict of the user home timeline print t.getHomeTimeline() Get a user avatar url *(no authentication needed)* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: - + + from twython import Twython + t = Twython() print t.getProfileImageUrl('ryanmcgrath', size='bigger') print t.getProfileImageUrl('mikehelmick') @@ -98,7 +103,8 @@ Get a user avatar url *(no authentication needed)* Search Twitter *(no authentication needed)* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: - + + from twython import Twython t = Twython() print t.search(q='python') @@ -109,6 +115,8 @@ streams.* :: + from twython import Twython + def on_results(results): """A callback to handle passed results. Wheeee. """