From f4614cc0676fdd8b6d5114d0f5a4a78808caf8e5 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:38:30 +1000 Subject: [PATCH] Restoring spammer blocking example. --- examples/block_spammer.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/block_spammer.py diff --git a/examples/block_spammer.py b/examples/block_spammer.py new file mode 100644 index 0000000..64b797d --- /dev/null +++ b/examples/block_spammer.py @@ -0,0 +1,20 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: block_spammer.py SomeoneAnnoying + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + twitter.report_spam(screen_name=target) +except TwythonError as e: + print(e)