From 3911011d202ae4f7f6f5021e550fa449b9f3574b Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sat, 17 May 2014 13:08:34 +1000 Subject: [PATCH 1/4] CLI script to display a tweet and the poster of that tweet using the tweet status ID through command line arguments. --- examples/show_status.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/show_status.py diff --git a/examples/show_status.py b/examples/show_status.py new file mode 100644 index 0000000..b4da77f --- /dev/null +++ b/examples/show_status.py @@ -0,0 +1,23 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: show_status.py 463604849372704768 + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("ID number of tweet to fetch: ") # For Python 3.x use: target = input("ID number of tweet to fetch: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + tweet = twitter.show_status(id=twid) + print(tweet["user"]["name"]+" ("+tweet["user"]["screen_name"]+"): "+tweet["text"]) +except TwythonError as e: + print(e) + +# This will print: Name (screen name): the content of the tweet selected. From f18af22c00e04277c80dc420708b1d613c04c559 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sat, 17 May 2014 13:17:13 +1000 Subject: [PATCH 2/4] Fixed the comment lines to relate to the action performed. --- examples/block_spammer.py | 2 +- examples/block_user.py | 2 +- examples/unblock_user.py | 2 +- examples/unfollow_user.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/block_spammer.py b/examples/block_spammer.py index c579904..89757f4 100644 --- a/examples/block_spammer.py +++ b/examples/block_spammer.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: block_spammer.py SomeoneAnnoying import sys diff --git a/examples/block_user.py b/examples/block_user.py index a06c5f0..be0a115 100644 --- a/examples/block_user.py +++ b/examples/block_user.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: block_user.py A_Twitter_Troll import sys diff --git a/examples/unblock_user.py b/examples/unblock_user.py index 80ea19c..57a6355 100644 --- a/examples/unblock_user.py +++ b/examples/unblock_user.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: unblock_user.py Not_So_Bad_After_All import sys diff --git a/examples/unfollow_user.py b/examples/unfollow_user.py index 2417035..1e708f6 100644 --- a/examples/unfollow_user.py +++ b/examples/unfollow_user.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: unfollow_user.py Not_So_Cool_Really import sys From 7a270707c56a91c5655502849b0379ea0b181b66 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sat, 24 May 2014 19:27:48 +1000 Subject: [PATCH 3/4] Fixing or removing true status in examples. --- examples/block_spammer.py | 2 +- examples/block_user.py | 2 +- examples/unblock_user.py | 2 +- examples/unfollow_user.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/block_spammer.py b/examples/block_spammer.py index 89757f4..64b797d 100644 --- a/examples/block_spammer.py +++ b/examples/block_spammer.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.report_spam(screen_name=target, follow="true") + twitter.report_spam(screen_name=target) except TwythonError as e: print(e) diff --git a/examples/block_user.py b/examples/block_user.py index be0a115..6b151ff 100644 --- a/examples/block_user.py +++ b/examples/block_user.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.create_block(screen_name=target, follow="true") + twitter.create_block(screen_name=target, skip_status="true") except TwythonError as e: print(e) diff --git a/examples/unblock_user.py b/examples/unblock_user.py index 57a6355..dcb6ebb 100644 --- a/examples/unblock_user.py +++ b/examples/unblock_user.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.destroy_block(screen_name=target, follow="true") + twitter.destroy_block(screen_name=target, skip_status="true") except TwythonError as e: print(e) diff --git a/examples/unfollow_user.py b/examples/unfollow_user.py index 1e708f6..863eda8 100644 --- a/examples/unfollow_user.py +++ b/examples/unfollow_user.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.destroy_friendship(screen_name=target, follow="true") + twitter.destroy_friendship(screen_name=target) except TwythonError as e: print(e) From 61ffc7ba44cfc1f0be53159fffdc0dd6dde94692 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Wed, 13 Aug 2014 17:02:57 +1000 Subject: [PATCH 4/4] Allow requests libs above minimum requirements too. --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 917c31a..b9fe523 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ coverage==3.6.0 -requests==2.1.0 -requests_oauthlib==0.4.0 +requests>=2.1.0 +requests_oauthlib>=0.4.0 python-coveralls==2.1.0 nose-cov==1.6 responses==0.2.0