Permalink
Browse files

Update Examples and LICENSE

Some examples were out of date (any trends example)
Renamed the core_examples dir. to examples
  • Loading branch information...
1 parent bb019d3 commit 4ac6436901d16394e264cd36234e55d24e4dba28 @michaelhelmick michaelhelmick committed Apr 19, 2013
View
@@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal
View
@@ -32,7 +32,7 @@ Installation
Usage
-----
-###### Authorization URL
+##### Authorization URL
```python
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.
-###### Handling the callback
+##### Handling the callback
```python
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*
-###### Getting a user home timeline
+##### Getting a user home timeline
```python
from twython import Twython
@@ -87,8 +87,9 @@ t = Twython(app_key, app_secret,
print t.getHomeTimeline()
```
-###### Catching exceptions
+##### Catching exceptions
> Twython offers three Exceptions currently: TwythonError, TwythonAuthError and TwythonRateLimitError
+
```python
from twython import Twython, TwythonAuthError
@@ -101,7 +102,7 @@ except TwythonAuthError as 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)
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
@@ -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
View
@@ -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
# Shortening URLs requires no authentication, huzzah
-shortURL = Twython.shortenURL("http://www.webs.com/")
+shortURL = Twython.shortenURL('http://www.webs.com/')
print shortURL
@@ -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')
@@ -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

0 comments on commit 4ac6436

Please sign in to comment.