-r --followers display followers of the given user (default)
-g --following display users the given user is following
-a --api-rate see your current API rate limit status
+ -i --ids prepend user id to each line. useful to tracking renames
AUTHENTICATION
Authenticate to Twitter using OAuth to see following/followers of private
from __future__ import print_function
-import os, sys, time, calendar, urllib2, httplib
+import os, sys, time, calendar
from getopt import gnu_getopt as getopt, GetoptError
+try:
+ import urllib.request as urllib2
+ import http.client as httplib
+except ImportError:
+ import urllib2
+ import httplib
+
# T-Follow (Twitter-Follow) application registered by @stalkr_
CONSUMER_KEY='USRZQfvFFjB6UvZIN2Edww'
CONSUMER_SECRET='AwGAaSzZa5r0TDL8RKCDtffnI9H9mooZUdOa95nw8'
from .auth import NoAuth
from .util import Fail, err
+
def parse_args(args, options):
"""Parse arguments from command-line to set options."""
- long_opts = ['help', 'oauth', 'followers', 'following', 'api-rate']
- short_opts = "horga"
+ long_opts = ['help', 'oauth', 'followers', 'following', 'api-rate', 'ids']
+ short_opts = "horgai"
opts, extra_args = getopt(args, short_opts, long_opts)
for opt, arg in opts:
options['followers'] = False
elif opt in ('-a', '--api-rate'):
options['api-rate' ] = True
+ elif opt in ('-i', '--ids'):
+ options['show_id'] = True
options['extra_args'] = extra_args
options = {
'oauth': False,
'followers': True,
- 'api-rate': False
+ 'api-rate': False,
+ 'show_id': False
}
try:
parse_args(args, options)
raise SystemExit(1)
for uid in user_ids:
- print(users[uid].encode("utf-8"))
+ if options['show_id']:
+ try:
+ print(str(uid) + "\t" + users[uid].encode("utf-8"))
+ except KeyError:
+ pass
+
+ else:
+ try:
+ print(users[uid].encode("utf-8"))
+ except KeyError:
+ pass
# print total on stderr to separate from user list on stdout
if options['followers']: