Reorganizing into a more package based structure, setting an initial (not working) setup.py file - this will be expanded soon

This commit is contained in:
Ryan McGrath 2009-07-28 03:13:48 -04:00
parent 4fed1e241f
commit d7d170cc3b
16 changed files with 1357 additions and 0 deletions

View file

@ -0,0 +1,7 @@
import tango
""" Instantiate Tango with no Authentication """
twitter = tango.setup()
trends = twitter.getCurrentTrends()
print trends

7
examples/daily_trends.py Normal file
View file

@ -0,0 +1,7 @@
import tango
""" Instantiate Tango with no Authentication """
twitter = tango.setup()
trends = twitter.getDailyTrends()
print trends

View file

@ -0,0 +1,8 @@
import tango, pprint
# Authenticate using Basic (HTTP) Authentication
twitter = tango.setup(authtype="Basic", username="example", password="example")
friends_timeline = twitter.getFriendsTimeline(count="150", page="3")
for tweet in friends_timeline:
print tweet["text"]

View file

@ -0,0 +1,6 @@
import tango
twitter = tango.setup(authtype="Basic", username="example", password="example")
mentions = twitter.getUserMentions(count="150")
print mentions

View file

@ -0,0 +1,7 @@
import tango
# We won't authenticate for this, but sometimes it's necessary
twitter = tango.setup()
user_timeline = twitter.getUserTimeline(screen_name="ryanmcgrath")
print user_timeline

View file

@ -0,0 +1,8 @@
import tango
# Getting the public timeline requires no authentication, huzzah
twitter = tango.setup()
public_timeline = twitter.getPublicTimeline()
for tweet in public_timeline:
print tweet["text"]

10
examples/rate_limit.py Normal file
View file

@ -0,0 +1,10 @@
import tango
# Instantiate with Basic (HTTP) Authentication
twitter = tango.setup(authtype="Basic", username="example", password="example")
# This returns the rate limit for the requesting IP
rateLimit = twitter.getRateLimitStatus()
# This returns the rate limit for the requesting authenticated user
rateLimit = twitter.getRateLimitStatus(rate_for="user")

View file

@ -0,0 +1,8 @@
import tango
""" Instantiate Tango with no Authentication """
twitter = tango.setup()
search_results = twitter.searchTwitter("WebsDotCom", rpp="50")
for tweet in search_results["results"]:
print tweet["text"]

7
examples/shorten_url.py Normal file
View file

@ -0,0 +1,7 @@
import tango
# Shortening URLs requires no authentication, huzzah
twitter = tango.setup()
shortURL = twitter.shortenURL("http://www.webs.com/")
print shortURL

11
examples/tango_setup.py Normal file
View file

@ -0,0 +1,11 @@
import tango
# Using no authentication and specifying Debug
twitter = tango.setup(debug=True)
# Using Basic Authentication
twitter = tango.setup(authtype="Basic", username="example", password="example")
# Using OAuth Authentication (Note: OAuth is the default, specify Basic if needed)
auth_keys = {"consumer_key": "yourconsumerkey", "consumer_secret": "yourconsumersecret"}
twitter = tango.setup(username="example", password="example", oauth_keys=auth_keys)

View file

@ -0,0 +1,5 @@
import tango
# Instantiate Tango with Basic (HTTP) Authentication
twitter = tango.setup(authtype="Basic", username="example", password="example")
twitter.updateProfileImage("myImage.png")

View file

@ -0,0 +1,5 @@
import tango
# Create a Tango instance using Basic (HTTP) Authentication and update our Status
twitter = tango.setup(authtype="Basic", username="example", password="example")
twitter.updateStatus("See how easy this was?")

View file

@ -0,0 +1,7 @@
import tango
""" Instantiate Tango with no Authentication """
twitter = tango.setup()
trends = twitter.getWeeklyTrends()
print trends