Update documentation for cursor example

[ci skip]
This commit is contained in:
Mike Helmick 2013-07-18 23:42:52 -04:00
parent 0fef3369ae
commit 0fa9b631c1
3 changed files with 67 additions and 18 deletions

View file

@ -7,6 +7,49 @@ This section covers methods to are part of Twython but not necessarily connected
*******************************************************************************
Cursor
------
This function returns a generator for Twitter API endpoints that are able to be pagintated in some way (either by cursor or since_id parameter)
The Old Way
^^^^^^^^^^^
.. code-block:: python
from twython import Twython
twitter = Twython(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
results = twitter.search(q='twitter')
if results.get('statuses'):
for result in results['statuses']:
print result['id_str']
The New Way
^^^^^^^^^^^
.. code-block:: python
from twython import Twython
twitter = Twython(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
results = twitter.cursor(t.search, q='twitter')
for result in results:
print result['id_str']
Another example:
.. code-block:: python
results = twitter.cursor(t.get_mentions_timeline)
for result in results:
print result['id_str']
HTML for Tweet
--------------