Update Examples and LICENSE
Some examples were out of date (any trends example) Renamed the core_examples dir. to examples
This commit is contained in:
parent
bb019d3a57
commit
4ac6436901
14 changed files with 44 additions and 67 deletions
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
||||||
The MIT License
|
The MIT License
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010 Ryan McGrath
|
Copyright (c) 2013 Ryan McGrath
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
11
README.md
11
README.md
|
|
@ -32,7 +32,7 @@ Installation
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
###### Authorization URL
|
##### Authorization URL
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from twython import Twython
|
from twython import Twython
|
||||||
|
|
@ -49,7 +49,7 @@ print 'Connect to Twitter via: %s' % auth_props['auth_url']
|
||||||
|
|
||||||
Be sure you have a URL set up to handle the callback after the user has allowed your app to access their data, the callback can be used for storing their final OAuth Token and OAuth Token Secret in a database for use at a later date.
|
Be sure you have a URL set up to handle the callback after the user has allowed your app to access their data, the callback can be used for storing their final OAuth Token and OAuth Token Secret in a database for use at a later date.
|
||||||
|
|
||||||
###### Handling the callback
|
##### Handling the callback
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from twython import Twython
|
from twython import Twython
|
||||||
|
|
@ -72,7 +72,7 @@ print auth_tokens
|
||||||
|
|
||||||
*Function definitions (i.e. getHomeTimeline()) can be found by reading over twython/endpoints.py*
|
*Function definitions (i.e. getHomeTimeline()) can be found by reading over twython/endpoints.py*
|
||||||
|
|
||||||
###### Getting a user home timeline
|
##### Getting a user home timeline
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from twython import Twython
|
from twython import Twython
|
||||||
|
|
@ -87,8 +87,9 @@ t = Twython(app_key, app_secret,
|
||||||
print t.getHomeTimeline()
|
print t.getHomeTimeline()
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Catching exceptions
|
##### Catching exceptions
|
||||||
> Twython offers three Exceptions currently: TwythonError, TwythonAuthError and TwythonRateLimitError
|
> Twython offers three Exceptions currently: TwythonError, TwythonAuthError and TwythonRateLimitError
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from twython import Twython, TwythonAuthError
|
from twython import Twython, TwythonAuthError
|
||||||
|
|
||||||
|
|
@ -101,7 +102,7 @@ except TwythonAuthError as e:
|
||||||
print e
|
print e
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Streaming API
|
##### Streaming API
|
||||||
*Usage is as follows; it's designed to be open-ended enough that you can adapt it to higher-level (read: Twitter must give you access)
|
*Usage is as follows; it's designed to be open-ended enough that you can adapt it to higher-level (read: Twitter must give you access)
|
||||||
streams.*
|
streams.*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
""" Instantiate Twython with no Authentication """
|
|
||||||
twitter = Twython()
|
|
||||||
trends = twitter.getCurrentTrends()
|
|
||||||
|
|
||||||
print trends
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
""" Instantiate Twython with no Authentication """
|
|
||||||
twitter = Twython()
|
|
||||||
trends = twitter.getDailyTrends()
|
|
||||||
|
|
||||||
print trends
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
# We won't authenticate for this, but sometimes it's necessary
|
|
||||||
twitter = Twython()
|
|
||||||
user_timeline = twitter.getUserTimeline(screen_name="ryanmcgrath")
|
|
||||||
|
|
||||||
print user_timeline
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
""" Instantiate Twython with no Authentication """
|
|
||||||
twitter = Twython()
|
|
||||||
search_results = twitter.search(q="WebsDotCom", rpp="50")
|
|
||||||
|
|
||||||
for tweet in search_results["results"]:
|
|
||||||
print "Tweet from @%s Date: %s" % (tweet['from_user'].encode('utf-8'),tweet['created_at'])
|
|
||||||
print tweet['text'].encode('utf-8'),"\n"
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
"""
|
|
||||||
You'll need to go through the OAuth ritual to be able to successfully
|
|
||||||
use this function. See the example oauth django application included in
|
|
||||||
this package for more information.
|
|
||||||
"""
|
|
||||||
twitter = Twython()
|
|
||||||
twitter.updateProfileImage("myImage.png")
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
"""
|
|
||||||
Note: for any method that'll require you to be authenticated (updating
|
|
||||||
things, etc)
|
|
||||||
you'll need to go through the OAuth authentication ritual. See the example
|
|
||||||
Django application that's included with this package for more information.
|
|
||||||
"""
|
|
||||||
twitter = Twython()
|
|
||||||
|
|
||||||
# OAuth ritual...
|
|
||||||
|
|
||||||
|
|
||||||
twitter.updateStatus(status="See how easy this was?")
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
""" Instantiate Twython with no Authentication """
|
|
||||||
twitter = Twython()
|
|
||||||
trends = twitter.getWeeklyTrends()
|
|
||||||
|
|
||||||
print trends
|
|
||||||
10
examples/get_user_timeline.py
Normal file
10
examples/get_user_timeline.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
from twython import Twython, TwythonError
|
||||||
|
|
||||||
|
# Requires Authentication as of Twitter API v1.1
|
||||||
|
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||||
|
try:
|
||||||
|
user_timeline = twitter.getUserTimeline(screen_name='ryanmcgrath')
|
||||||
|
except TwythonError as e:
|
||||||
|
print e
|
||||||
|
|
||||||
|
print user_timeline
|
||||||
12
examples/search_results.py
Normal file
12
examples/search_results.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
from twython import Twython, TwythonError
|
||||||
|
|
||||||
|
# Requires Authentication as of Twitter API v1.1
|
||||||
|
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||||
|
try:
|
||||||
|
search_results = twitter.search(q="WebsDotCom", rpp="50")
|
||||||
|
except TwythonError as e:
|
||||||
|
print e
|
||||||
|
|
||||||
|
for tweet in search_results["results"]:
|
||||||
|
print "Tweet from @%s Date: %s" % (tweet['from_user'].encode('utf-8'),tweet['created_at'])
|
||||||
|
print tweet['text'].encode('utf-8'),"\n"
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from twython import Twython
|
from twython import Twython
|
||||||
|
|
||||||
# Shortening URLs requires no authentication, huzzah
|
# Shortening URLs requires no authentication, huzzah
|
||||||
shortURL = Twython.shortenURL("http://www.webs.com/")
|
shortURL = Twython.shortenURL('http://www.webs.com/')
|
||||||
|
|
||||||
print shortURL
|
print shortURL
|
||||||
5
examples/update_profile_image.py
Normal file
5
examples/update_profile_image.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from twython import Twython
|
||||||
|
|
||||||
|
# Requires Authentication as of Twitter API v1.1
|
||||||
|
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||||
|
twitter.updateProfileImage('myImage.png')
|
||||||
9
examples/update_status.py
Normal file
9
examples/update_status.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
from twython import Twython, TwythonError
|
||||||
|
|
||||||
|
# Requires Authentication as of Twitter API v1.1
|
||||||
|
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||||
|
|
||||||
|
try:
|
||||||
|
twitter.updateStatus(status='See how easy this was?')
|
||||||
|
except TwythonError as e:
|
||||||
|
print e
|
||||||
Loading…
Add table
Add a link
Reference in a new issue