Пример #1
0
    def localinit(self):
        OAUTH_FILENAME = self.connection.config.get("twitter", "oauth_cache")
        CONSUMER_KEY = self.connection.config.get("twitter", "consumer_key")
        CONSUMER_SECRET = self.connection.config.get(
            "twitter", "consumer_secret")

        try:
            if not os.path.exists(OAUTH_FILENAME):
                oauth_dance(
                    "Lampstand", CONSUMER_KEY, CONSUMER_SECRET,
                    OAUTH_FILENAME)

            self.oauth_token, self.oauth_token_secret = read_token_file(
                OAUTH_FILENAME)

            self.twitter = Twitter(
                auth=OAuth(
                    self.oauth_token,
                    self.oauth_token_secret,
                    CONSUMER_KEY,
                    CONSUMER_SECRET),
                secure=True,
                domain='api.twitter.com')
        except:
            pass
Пример #2
0
    def __init__(self, connection):
        self.logger = logging.getLogger(self.__name)
        self.dbconnection = connection.dbconnection

        self.output_channel = "#%s" % connection.config.get(
            "lowflyingrocks",
            "channel")

        # OAUTH_FILENAME = os.environ.get(
        #    'HOME',
        #    '') + os.sep + '.lampstand_oauth'
        OAUTH_FILENAME = connection.config.get("twitter", "oauth_cache")
        CONSUMER_KEY = connection.config.get("twitter", "consumer_key")
        CONSUMER_SECRET = connection.config.get("twitter", "consumer_secret")

        try:
            if not os.path.exists(OAUTH_FILENAME):
                oauth_dance(
                    "Lampstand", CONSUMER_KEY, CONSUMER_SECRET,
                    OAUTH_FILENAME)

            self.oauth_token, self.oauth_token_secret = read_token_file(
                OAUTH_FILENAME)

            self.twitter = Twitter(
                auth=OAuth(
                    self.oauth_token,
                    self.oauth_token_secret,
                    CONSUMER_KEY,
                    CONSUMER_SECRET),
                secure=True,
                domain='api.twitter.com')
        except:
            self.twitter = False
Пример #3
0
    def localinit(self):
        OAUTH_FILENAME = self.connection.config.get("twitter", "oauth_cache")
        CONSUMER_KEY = self.connection.config.get("twitter", "consumer_key")
        CONSUMER_SECRET = self.connection.config.get(
            "twitter", "consumer_secret")

        try:
            if not os.path.exists(OAUTH_FILENAME):
                oauth_dance(
                    "Lampstand", CONSUMER_KEY, CONSUMER_SECRET,
                    OAUTH_FILENAME)

            self.oauth_token, self.oauth_token_secret = read_token_file(
                OAUTH_FILENAME)

            self.twitter = Twitter(
                auth=OAuth(
                    self.oauth_token,
                    self.oauth_token_secret,
                    CONSUMER_KEY,
                    CONSUMER_SECRET),
                secure=True,
                domain='api.twitter.com')
        except:
            pass
Пример #4
0
def get_twitter(debug=False):
    # This is secret and key of my app "ibread"
    # this is set up on twitter.com
    CONSUMER_KEY = "NXdiUFv7ZqhO5Ojr8GocA"
    CONSUMER_SECRET = "CMRgb7BHpHLlcZ0NqHF06pWbFtv1zPqV98KTaFxV2YQ"
    #oauth_filename = os.environ.get('HOME', '') + os.sep + '.my_twitter_oauth'
    oauth_filename = sys.path[0] + os.sep + 'my_twitter_oauth'
    
    if debug:
        print oauth_filename
    
    # if did not found the auth file, create one
    if not os.path.exists(oauth_filename):
        oauth_dance("ibread", CONSUMER_KEY, CONSUMER_SECRET, oauth_filename)

    oauth_token, oauth_token_secret = read_token_file(oauth_filename)
    
    if debug:
        print oauth_token, oauth_token_secret

    tw = Twitter(
        auth=OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET),
        secure=True,
        api_version='1',
        domain='api.twitter.com')
    
    return tw
Пример #5
0
def main():
    consumer_key = settings.SRTMC_CONSUMER_KEY
    consumer_secret = settings.SRTMC_CONSUMER_SECRET
    oauth_filename = os.path.join(_base, ".twitter_srtmc_oauth")
    
    if not os.path.exists(oauth_filename):
        oauth_dance("SRTMC Alerts", consumer_key, consumer_secret, oauth_filename)
    
    oauth_token, oauth_token_secret = read_token_file(oauth_filename)  
    alerts = SrtmcAlerts(oauth_token, oauth_token_secret, consumer_key, consumer_secret)
    alerts.check_latest_status()    
def main():
    consumer_key = settings.WSDOT_TRAFFIC_CONSUMER_KEY
    consumer_secret = settings.WSDOT_TRAFFIC_CONSUMER_SECRET
    oauth_filename = os.path.join(_base, ".twitter_wsdot_traffic_oauth")
    
    if not os.path.exists(oauth_filename):
        oauth_dance("WSDOT Traffic", consumer_key, consumer_secret, oauth_filename)
    
    oauth_token, oauth_token_secret = read_token_file(oauth_filename)  
    incidents = SeattleIncidents(oauth_token, oauth_token_secret, consumer_key, consumer_secret)
    incidents.check_latest_status()    
Пример #7
0
def main():
    consumer_key = settings.WSFERRIES_CONSUMER_KEY
    consumer_secret = settings.WSFERRIES_CONSUMER_SECRET 
    oauth_filename = os.path.join(_base, ".twitter_wsdot_ferries_oauth")
    
    if not os.path.exists(oauth_filename):
        oauth_dance("WSDOT Ferries", consumer_key, consumer_secret, oauth_filename)
    
    oauth_token, oauth_token_secret = read_token_file(oauth_filename)
    route_alerts = RouteAlerts(oauth_token, oauth_token_secret, consumer_key, consumer_secret)
    latest = route_alerts.get_bulletins()
    route_alerts.check_bulletins(latest)
Пример #8
0
def authen():
    """
    Authenticate with Twitter OAuth
    """
    # When using rainbow stream you must authorize.
    twitter_credential = os.environ.get(
        'HOME', os.environ.get('USERPROFILE', '')) + os.sep + '.rainbow_oauth'
    if not os.path.exists(twitter_credential):
        oauth_dance("Rainbow Stream", CONSUMER_KEY, CONSUMER_SECRET,
                    twitter_credential)
    oauth_token, oauth_token_secret = read_token_file(twitter_credential)
    return OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY,
                 CONSUMER_SECRET)
Пример #9
0
    def __init__(self, connection):
        self.channelMatch = [
            re.compile(
                '%s: Shorten that( URL)?' %
                connection.nickname,
                re.IGNORECASE),
            # 0
            re.compile(
                '%s: Shorten (.*?)\'s? (link|url)' %
                connection.nickname,
                re.IGNORECASE),
            # 1
            re.compile(
                '%s: Shorten this (link|url): (.*)$' %
                connection.nickname,
                re.IGNORECASE),
            # 2
            re.compile('.*https?\:\/\/', re.IGNORECASE)]  # 3
        self.dbconnection = connection.dbconnection
        self.bitly = bitly_api.Connection(
            connection.config.get(
                "bitly", "username"), connection.config.get(
                "bitly", "apikey"))

        self.yt_service = gdata.youtube.service.YouTubeService()
        self.yt_service.ssl = True

        self.lastlink = {}

        OAUTH_FILENAME = os.environ.get(
            'HOME',
            '') + os.sep + '.lampstand_oauth'
        CONSUMER_KEY = connection.config.get("twitter", "consumer_key")
        CONSUMER_SECRET = connection.config.get("twitter", "consumer_secret")

        if not os.path.exists(OAUTH_FILENAME):
            oauth_dance(
                "Lampstand", CONSUMER_KEY, CONSUMER_SECRET,
                OAUTH_FILENAME)

        self.oauth_token, self.oauth_token_secret = read_token_file(
            OAUTH_FILENAME)

        self.twitter = Twitter(
            auth=OAuth(
                self.oauth_token,
                self.oauth_token_secret,
                CONSUMER_KEY,
                CONSUMER_SECRET),
            secure=True,
            domain='api.twitter.com')
Пример #10
0
 def __init__(self):
     """If the user is not authorized yet, do the OAuth dance and save the
     credentials in her home folder for future incovations.
     Then read the credentials and return the authorized Twitter API object."""
     if not os.path.exists(OAUTH_FILENAME):
         oauth_dance("@swissbolli's Monday Twitter Backup",
             CONSUMER_KEY, CONSUMER_SECRET, OAUTH_FILENAME
         )
     oauth_token, oauth_token_secret = read_token_file(OAUTH_FILENAME)
     self.api = Twitter(
         auth=OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET),
         retry=5
     )
     user = self.api.account.settings(_method='GET')
     self.screen_name = user['screen_name']
def main():
    args = parse_arguments()

    # When using twitter stream you must authorize.
    oauth_filename = os.path.join(os.getenv("HOME", ""), ".twitter-stream-archiver_oauth")
    if not os.path.exists(oauth_filename):
            oauth_dance("Twitter-Stream-Archiver", CONSUMER_KEY, CONSUMER_SECRET, oauth_filename)
    oauth_token, oauth_token_secret = read_token_file(oauth_filename)
    auth = OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET)

    # These arguments are optional:
    stream_args = dict(
        timeout=args.timeout,
        block=not args.no_block,
        heartbeat_timeout=args.heartbeat_timeout)

    query_args = dict()
    if args.track_keywords:
        query_args['track'] = args.track_keywords
    if args.track_users:
        query_args['follow'] = args.track_users
    if args.track_locations:
        query_args['locations'] = args.track_locations

    stream = TwitterStream(auth=auth, **stream_args)
    if query_args:
        tweet_iter = stream.statuses.filter(**query_args)
    else:
        tweet_iter = stream.statuses.sample()

    # Iterate over the sample stream.
    for tweet in tweet_iter:
        # You must test that your tweet has text. It might be a delete
        # or data message.
        if tweet is None:
            sys.stderr.write("-- None --\n")
        elif tweet is Timeout:
            sys.stderr.write("-- Timeout --\n")
        elif tweet is HeartbeatTimeout:
            sys.stderr.write("-- Heartbeat Timeout --\n")
        elif tweet is Hangup:
            sys.stderr.write("-- Hangup --\n")
        elif tweet.get('text'):
            sys.stdout.write(json.dumps(tweet))
            sys.stdout.write('\n')
            sys.stdout.flush()
        else:
            sys.stderr.write("-- Some data: " + str(tweet) + "\n")
Пример #12
0
def generate_following_token():
    oauth_token, oauth_token_secret = oauth_dance("Twitter-Follow",
            FOLLOWING_CONSUMER_KEY, FOLLOWING_CONSUMER_SECRET)
    auth_file = open('./auth_users_follow', 'a')
    auth_file.write('%s %s\n' % (oauth_token, oauth_token_secret))
    auth_file.close()
    return
Пример #13
0
def generate_archiever_token():
    oauth_token, oauth_token_secret =  oauth_dance("Twitter-Archiver",
            ARCHIEVER_CONSUMER_KEY,ARCHIEVER_CONSUMER_SECRET)
    auth_file = open('./auth_users', 'a')
    auth_file.write('%s %s\n' % (oauth_token, oauth_token_secret))
    auth_file.close()
    return
def login_and_get_twitter():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    CREDENTIALS_FILE = './twitter_credentials.txt'
    TOKEN_FILE = './twitter_token.oauth'  # in the current directory
#     try:
    (app_name, consumer_key, consumer_secret) = read_credentials_file(CREDENTIALS_FILE)
#     except IOError:
#         print(TOKEN_FILE + " not found")
    
    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
        logging.info('read token from file success')
    except IOError as e:
        logging.info('read token from file failed, requesting new token')
        (oauth_token, oauth_token_secret) = oauth_dance(app_name, consumer_key,
                consumer_secret)
  
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)

    return twitter.Twitter(domain='api.twitter.com', api_version='1.1',
                        auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
                        consumer_key, consumer_secret))
Пример #15
0
def get_twitter_tools(oauthfile):
    #--- register oauth tokens -------------------------------------------
    try:
        oauth_token, oauth_token_secret = read_token_file(oauthfile)
    except IOError:
        print 'OAuth file {} not found'.format(oauthfile)
        response = raw_input(
            'Do you want to initiate a new oauth dance (y or n)? ')
        if not (len(response) > 0 and response[0].upper() == 'Y'):
            oauth_token = oauth_token_secret = ''
        else:
            oauth_token, oauth_token_secret = oauth_dance(
                'Brilliant App',
                CONSUMER_KEY,
                CONSUMER_SECRET,
                token_filename=oauthfile)

    #--- t1 = Twitter Search API, t2 = Twitter REST API ------------------
    t1 = Twitter(domain='search.twitter.com')
    t2 = Twitter(auth=OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY,
                            CONSUMER_SECRET),
                 secure=True,
                 api_version='1',
                 domain='api.twitter.com')
    return t1, t2
Пример #16
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = ''
    CONSUMER_KEY = '2JRLM23QHyLyBABuqg4tqQ'
    CONSUMER_SECRET = 'avpoP356DDKbHtTRiicjKBC01yXqfaI8QCgfZebmjA'
    TOKEN_FILE = 'auth/twitter.oauth'
    '''
        consumer_key = '2JRLM23QHyLyBABuqg4tqQ'
        consumer_secret = 'avpoP356DDKbHtTRiicjKBC01yXqfaI8QCgfZebmjA'
        access_token = '20692466-4kkQfaO8V0e2cVBDzfYg4EkFdQO9u0CNZLoP8Xma5'
        access_token_secret = '0bUGan28R0Dt2f0NIIjA2AcCkNUelANx674aWUH9Oj08f'
    '''
    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token,
         oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                           CONSUMER_SECRET)

        if not os.path.isdir('auth'):
            os.mkdir('auth')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #17
0
 def initialize(self):
     c = self.client.consumer
     try:
         ret = oauth_dance(APPLICATION_NAME, c.key, c.secret)
         return ret
     except TwitterHTTPError, e:
         logging.error(e)
Пример #18
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = ''
    CONSUMER_KEY = '2JRLM23QHyLyBABuqg4tqQ'
    CONSUMER_SECRET = 'avpoP356DDKbHtTRiicjKBC01yXqfaI8QCgfZebmjA'
    TOKEN_FILE = 'auth/twitter.oauth'

    '''
        consumer_key = '2JRLM23QHyLyBABuqg4tqQ'
        consumer_secret = 'avpoP356DDKbHtTRiicjKBC01yXqfaI8QCgfZebmjA'
        access_token = '20692466-4kkQfaO8V0e2cVBDzfYg4EkFdQO9u0CNZLoP8Xma5'
        access_token_secret = '0bUGan28R0Dt2f0NIIjA2AcCkNUelANx674aWUH9Oj08f'
    '''
    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('auth'):
            os.mkdir('auth')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #19
0
def login():

    config = ConfigParser.ConfigParser()
    config.readfp(open("twitter.config","rb"))

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = config.get('account', 'appname')
    CONSUMER_KEY = config.get('account', 'consumerkey')
    CONSUMER_SECRET = config.get('account', 'consumersecret')
    ACCESS_TOKEN = config.get('account', 'accesstoken')
    ACCESS_TOKEN_SECRET = config.get('account', 'accesstokensecret')
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        if ACCESS_TOKEN != None and ACCESS_TOKEN_SECRET != None:
            oauth_token = ACCESS_TOKEN
            oauth_token_secret = ACCESS_TOKEN_SECRET
        else:
            (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #20
0
def generate_following_token():
    oauth_token, oauth_token_secret = oauth_dance("Twitter-Follow",
                                                  FOLLOWING_CONSUMER_KEY,
                                                  FOLLOWING_CONSUMER_SECRET)
    auth_file = open('./auth_users_follow', 'a')
    auth_file.write('%s %s\n' % (oauth_token, oauth_token_secret))
    auth_file.close()
    return
Пример #21
0
def generate_archiever_token():
    oauth_token, oauth_token_secret = oauth_dance("Twitter-Archiver",
                                                  ARCHIEVER_CONSUMER_KEY,
                                                  ARCHIEVER_CONSUMER_SECRET)
    auth_file = open('./auth_users', 'a')
    auth_file.write('%s %s\n' % (oauth_token, oauth_token_secret))
    auth_file.close()
    return
Пример #22
0
 def handle(self, *args, **options):
     (oauth_token, oauth_token_secret) = oauth_dance('tweet_saved', tweet.tweeter.CONSUMER_KEY, tweet.tweeter.CONSUMER_SECRET)
     self.stdout.write(
         "Please add\n"
         "TWEET_SAVED_OAUTH_TOKEN = '%s'\n"
         "TWEET_SAVED_OAUTH_TOKEN_SECRET = '%s'\n"
         "to your settings.py\n" % (oauth_token, oauth_token_secret)
     )
def get_auth_tokens(stdout):
    oauth_token, oauth_secret = oauth_dance(
        app_name='django-latest-tweets',
        consumer_key=settings.TWITTER_CONSUMER_KEY,
        consumer_secret=settings.TWITTER_CONSUMER_SECRET)

    stdout.write("\nNow add the following lines to your settings.py:\n\n")
    stdout.write("TWITTER_OAUTH_TOKEN = '%s'\n" % (oauth_token,))
    stdout.write("TWITTER_OAUTH_SECRET = '%s'\n\n" % (oauth_secret,))
    def handle_noargs(self, **options):
        oauth_token, oauth_token_secret = oauth_dance(
            settings.TWITTER_APP_NAME,
            settings.TWITTER_CONSUMER_KEY,
            settings.TWITTER_CONSUMER_SECRET
        )

        print 'TWITTER_TOKEN =', oauth_token
        print 'TWITTER_TOKEN_SECRET =', oauth_token_secret
def get_auth_tokens(stdout):
    oauth_token, oauth_secret = oauth_dance(
        app_name='django-latest-tweets',
        consumer_key=settings.TWITTER_CONSUMER_KEY,
        consumer_secret=settings.TWITTER_CONSUMER_SECRET)

    stdout.write("\nNow add the following lines to your settings.py:\n\n")
    stdout.write("TWITTER_OAUTH_TOKEN = '%s'\n" % (oauth_token, ))
    stdout.write("TWITTER_OAUTH_SECRET = '%s'\n\n" % (oauth_secret, ))
Пример #26
0
def get_all_tweets(screen_name):
    #Twitter only allows access to a users most recent 3240 tweets with this method

    #authorize twitter, initialize tweepy
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    (access_key, access_secret) = oauth_dance('', consumer_key,
                                              consumer_secret)
    auth.set_access_token(access_key, access_secret)
    api = tweepy.API(auth)

    #initialize a list to hold all the tweepy Tweets
    alltweets = []

    #make initial request for most recent tweets (200 is the maximum allowed count)
    new_tweets = api.user_timeline(screen_name=screen_name, count=200)

    #save most recent tweets
    alltweets.extend(new_tweets)

    #save the id of the oldest tweet less one
    oldest = alltweets[-1].id - 1

    #keep grabbing tweets until there are no tweets left to grab

    while len(new_tweets) > 0:
        print "getting tweets before %s" % (oldest)

        #all subsiquent requests use the max_id param to prevent duplicates
        new_tweets = api.user_timeline(screen_name=screen_name,
                                       count=200,
                                       max_id=oldest)

        #save most recent tweets
        alltweets.extend(new_tweets)

        #update the id of the oldest tweet less one
        oldest = alltweets[-1].id - 1

        print "...%s tweets downloaded so far" % (len(alltweets))

    #transform the tweepy tweets into a 2D array that will populate the csv
    outtweets = [[tweet.id_str, tweet.created_at,
                  tweet.text.encode("utf-8")] for tweet in alltweets]

    tweets = []
    fname = '%s_tweets.txt' % screen_name
    print fname
    f = open(fname, 'w')
    for t in outtweets:
        txt = t[2]
        words = txt.split()
        #print words[0]
        if (words[0] != "RT"):
            f.write(txt)
            f.write('\n')

    f.close()
Пример #27
0
def twitterAuth(config, OAUTH_TWITTER):
    HOME = os.environ.get('HOME', '')
    twitter_user = config.get("twitter", "username")
    OAUTH_FILENAME = HOME + os.sep + '.lifesteam_oauth_' + twitter_user
    CONSUMER_KEY = config.get("twitter", "consumer_key")
    CONSUMER_SECRET = config.get("twitter", "consumer_secret")

    if not os.path.exists(OAUTH_FILENAME):
        oauth_dance("Lifestream", CONSUMER_KEY, CONSUMER_SECRET,
                    OAUTH_FILENAME)

    oauth_token, oauth_token_secret = read_token_file(OAUTH_FILENAME)

    return Twitter(auth=OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY,
                              CONSUMER_SECRET),
                   secure=True,
                   api_version='1.1',
                   domain='api.twitter.com')
Пример #28
0
def oauth_login(app_name='', consumer_key='',consumer_secret='', token_file='out/twitter.oauth'):
    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError, e:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,consumer_secret)
        
        if not os.path.isdir('out'): 
            os.mkdir('out')
        write_token_file(token_file, access_token, access_token_secret)
        print >> sys.stderr, "OAuth Success. Token file stored to", token_file
Пример #29
0
def get_twitter_stream():

	try:
		(oauth_token, oauth_token_secret)= read_token_file(token_file)
	except IOError, e:
		(oauth_token, oauth_token_secret)=oauth_dance (app_name, consumer_key, consumer_secret)

		if not os.path.isdir(token_path):
			os.mkdir(token_path)
	
		write_token_file(token_file, oauth_token, oauth_token_secret)
Пример #30
0
def twitterAuth(config, OAUTH_TWITTER):
    HOME = os.environ.get('HOME', '')
    twitter_user = config.get("twitter", "username")
    OAUTH_FILENAME = HOME + os.sep + '.lifesteam_oauth_' + twitter_user
    CONSUMER_KEY = config.get("twitter", "consumer_key")
    CONSUMER_SECRET = config.get("twitter", "consumer_secret")

    if not os.path.exists(OAUTH_FILENAME):
        oauth_dance(
            "Lifestream", CONSUMER_KEY, CONSUMER_SECRET,
            OAUTH_FILENAME)

    oauth_token, oauth_token_secret = read_token_file(OAUTH_FILENAME)

    return Twitter(
        auth=OAuth(
            oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET),
        secure=True,
        api_version='1.1',
        domain='api.twitter.com')
def oauth_login(app_name=APP_NAME,consumer_key=CONSUMER_KEY,consumer_secret=CONSUMER_SECRET,token_file='out/twitter_oauth'):

	try:
		(oauth_token, oauth_token_secret) = read_token_file(token_file)
	except IOError, e:
		(oauth_token, oauth_token_secret) = oauth_dance('deathcape', consumer_key, consumer_secret)

		if not os.path.isdir('out'):
			os.mkdir('out')
		write_token_file(token_file,oatuh_token,oauth_token_secret)
		print >> sys.stderr, "OAuth Success. Token file stored to", token_file
Пример #32
0
def oauth_login(app_name=APP_NAME,consumer_key=CONSUMER_KEY,consumer_secret=CONSUMER_SECRET,token_file='out/twitter_oauth'):

	try:
		(oauth_token, oauth_token_secret) = read_token_file(token_file)
	except IOError, e:
		(oauth_token, oauth_token_secret) = oauth_dance('deathcape', consumer_key, consumer_secret)

		if not os.path.isdir('out'):
			os.mkdir('out')
		write_token_file(token_file,oatuh_token,oauth_token_secret)
		print >> sys.stderr, "OAuth Success. Token file stored to", token_file
Пример #33
0
def authen():
    """
    Authenticate with Twitter OAuth
    """
    # When using rainbow stream you must authorize.
    twitter_credential = os.environ.get(
        'HOME',
        os.environ.get(
            'USERPROFILE',
            '')) + os.sep + '.rainbow_oauth'
    if not os.path.exists(twitter_credential):
        oauth_dance("Rainbow Stream",
                    CONSUMER_KEY,
                    CONSUMER_SECRET,
                    twitter_credential)
    oauth_token, oauth_token_secret = read_token_file(twitter_credential)
    return OAuth(
        oauth_token,
        oauth_token_secret,
        CONSUMER_KEY,
        CONSUMER_SECRET)
Пример #34
0
def check_twitter_auth():
    authorized = False
    if os.path.isfile(fn):  # Does the token file exist?
        tokens = twitter.oauth.read_token_file(fn)
        #print 'OAuth tokens exist, will try to authorize with them...'
        twapi = twitter.Twitter(auth=twitter.OAuth(token=tokens[0],
                                                   token_secret=tokens[1],
                                                   consumer_secret=con_secret,
                                                   consumer_key=con_key))
        try:
            result = twapi.account.verify_credentials()
            twitter_id = result['id']
            twitter_handle = result['screen_name']
            #print 'Good, we seem to be authorized for username %s with id %d' % (twitter_handle, int(twitter_id))
            authorized = twapi
        except twitter.TwitterError as e:
            logging.debug(
                "Call failed, we don't seem to be authorized with existing credentials.  Deleting..."
            )
            print e
            os.remove(fn)

    if authorized == False:  # If not authorized, do the OAuth dance
        logging.debug("Authorizing the app...")
        tokens = oauth_dance(app_name='TreeOfLight',
                             consumer_key=con_key,
                             consumer_secret=con_secret,
                             token_filename=fn)
        os.chmod(fn, stat.S_IRUSR | stat.S_IWUSR)  # Read/write, user-only
        #
        # Get an open API object for Twitter
        #
        twapi = twitter.Twitter(auth=twitter.OAuth(token=tokens[0],
                                                   token_secret=tokens[1],
                                                   consumer_secret=con_secret,
                                                   consumer_key=con_key))
        try:  # Is this going to work?
            result = twapi.account.verify_credentials()
            twitter_id = result['id']
            twitter_handle = result['screen_name']
            logging.debug(
                "Good, we seem to be authorized for username %s with id %d" %
                (twitter_handle, int(twitter_id)))
            authorized = twapi
        except twitter.TwitterError as e:  # Something bad happening, abort, abort!
            logging.debug(
                "Call failed, we don't seem to be authorized with new credentials.  Deleting..."
            )
            print e
            os.remove(fn)

    return authorized
Пример #35
0
def authen():
    """
    Authenticate with Twitter OAuth
    """
    CONSUMER_KEY = '9v0gwkxQeWwnCXfMwuIevRAZA'
    CONSUMER_SECRET = 'wHP4NZ1tHxVFFyTAM8KGKHpxmPg3ErY4ibYxLftxjrPBKmJLvt'
    # When using rainbow stream you must authorize.
    twitter_credential = os.environ.get(
        'HOME',
        os.environ.get(
            'USERPROFILE',
            '')) + os.sep + '.askbot_oauth'
    if not os.path.exists(twitter_credential):
        oauth_dance("Dwango Ask",
                    CONSUMER_KEY,
                    CONSUMER_SECRET,
                    twitter_credential)
    oauth_token, oauth_token_secret = read_token_file(twitter_credential)
    return OAuth(
        oauth_token,
        oauth_token_secret,
        CONSUMER_KEY,
        CONSUMER_SECRET)
Пример #36
0
def oauth_login(app_name="", consumer_key="", consumer_secret="", token_file="out/twitter.oauth"):
    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key, consumer_secret)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(token_file, access_token, access_token_secret)

        print >> sys.stderr, "OAuth Success. Token file stored to", token_file

    return twitter.Twitter(domain='api.twitter.com', api_version='1', auth=twitter.oauth.OAuth(access_token, access_token_secret, consumer_key, consumer_secret))
Пример #37
0
 def login(self):
     '''
     Performs the OAuth dance and returns a Twitter API object. 
     '''    
     #TODO: Add these keys to a config file instead of having them hardcoded.
     consumer_key = "nAy4J74aqtxxOASxOb8pPQ"
     consumer_secret = "JOapiSE9hTcCjwTAk8DoHUYKOeRGtaFZwK1IcxBjxJQ"
     app_name = "TestGeorge"
     
     (oauth_token, oauth_token_secret) = oauth_dance(app_name, consumer_key, consumer_secret)
     self.twitter_object_handle =  twitter.Twitter(domain='api.twitter.com', api_version='1', 
                                   auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
                                   consumer_key, consumer_secret))
     return self.twitter_object_handle
Пример #38
0
def main(args=[]):
    parser = argparse.ArgumentParser(description="Time spent tweeting bot")

    # oauth file
    parser.add_argument(
        "--oauth-file", dest="oauth_filename", help="OAuth credentials", default=join(script_dir, ".twitter_oauth")
    )
    parser.add_argument(
        "--history-file", dest="history_filename", help="History filename", default=join(script_dir, ".twitter_history")
    )

    options = parser.parse_args(args)

    if not os.path.exists(options.oauth_filename):
        from twitter.oauth_dance import oauth_dance

        oauth_dance("timespenttweeting", CONSUMER_KEY, CONSUMER_SECRET, options.oauth_filename)

    oauth_token, oauth_secret = twitter.read_token_file(options.oauth_filename)
    print "token is %s, secret is %s" % (oauth_token, oauth_secret)

    t = TimeTweeter(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET, options.history_filename)
    t.run()
Пример #39
0
def oauth_login(app_name=APP_NAME,
                consumer_key=CONSUMER_KEY, 
                consumer_secret=CONSUMER_SECRET, 
                token_file='auth/twitter.oauth'):

    # try to read the token file
    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError, e: # if it fails, create the token and write it to disk
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,
                                                          consumer_secret)
        if not os.path.isdir('auth'):
            os.mkdir('auth')
        write_token_file(token_file, access_token, access_token_secret)
        print >> sys.stderr, "OAuth Success. Token file stored to", token_file
def oauth_login(
    app_name=APP_NAME, consumer_key=CONSUMER_KEY, consumer_secret=CONSUMER_SECRET, token_file="out/twitter.oauth"
):

    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError, e:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key, consumer_secret)

        if not os.path.isdir("out"):
            os.mkdir("out")

        write_token_file(token_file, access_token, access_token_secret)

        print >>sys.stderr, "OAuth Success. Token file stored to", token_file
Пример #41
0
def oauth_login(app_name="Analyzing_Twitter",
                consumer_key="1H3NUrvWq1OGuQVh9420Spvld",
                consumer_secret="3YmiaPqyiuN00TNlHCKSgLLqfvrFr088nKT7qaukrtZXmZrx9R",
                token_file=''):

    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError as e:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,consumer_secret)
        if not os.path.isdir('out'):
            os.mkdir('out')
        write_token_file(token_file, access_token, access_token_secret)
        print (sys.stderr, "OAuth Success. Token file stored to", token_file)
    return twitter.Twitter(auth=twitter.oauth.OAuth(access_token, access_token_secret,
                           consumer_key, consumer_secret))
    def doTwitterAuth(self, consumer_key, consumer_secret):
        (oauth_token, oauth_token_secret) = self._redis.mget(['oauth_token',
                'oauth_token_secret'])
        if not oauth_token and not oauth_token_secret:
            try:
                (oauth_token, oauth_token_secret) = oauth_dance('this application'
                        , consumer_key, consumer_secret)
                self._redis.mset({'oauth_token': oauth_token, 'oauth_token_secret'
                                 : oauth_token_secret})
            except twitter.api.TwitterHTTPError, e:

                                                    # probably an invalid pin

                print 'Unable to perform authentication with OAuth. Aborting'
                raise e
Пример #43
0
def do_oauth_dance(oauth_filename, key, secret):
    """
    Prompts user to create OAuth token and token secret and then saves them
    in filename
    """
    print(('OAuth file {} not found'.format(oauth_filename)))
    request = 'Do you want to initiate a new oauth dance (y or n)? '
    response = raw_input(request)
    if len(response) > 0 and response[0].upper() == 'Y':
        token, token_secret = oauth_dance('Eye spy you!',
                                            key,
                                            secret,
                                            oauth_filename)
    else:
        token = token_secret = ''
    return token, token_secret
Пример #44
0
def login():
    #loging to twitter application
    APP_NAME = "Finance_Harvest"
    CONSUMER_KEY = "Bkvk7JFZmzaVpLjGAWBtxQ"
    CONSUMER_SECRET = "y9tugnYJeU8aMNW44o6hwWHC3QVktCYtW3RDm3Mdk"
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        print e.errno, e.strerror
        (oauth_token,
         oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                           CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #45
0
    def login(self):
        '''
        Performs the OAuth dance and returns a Twitter API object. 
        '''
        #TODO: Add these keys to a config file instead of having them hardcoded.
        consumer_key = "nAy4J74aqtxxOASxOb8pPQ"
        consumer_secret = "JOapiSE9hTcCjwTAk8DoHUYKOeRGtaFZwK1IcxBjxJQ"
        app_name = "TestGeorge"

        (oauth_token,
         oauth_token_secret) = oauth_dance(app_name, consumer_key,
                                           consumer_secret)
        self.twitter_object_handle = twitter.Twitter(
            domain='api.twitter.com',
            api_version='1',
            auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
                                     consumer_key, consumer_secret))
        return self.twitter_object_handle
Пример #46
0
def login():
    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'SocialWebJuanPavez'
    CONSUMER_KEY = 'XTtlNpLJRamXyuJOvX1g'
    CONSUMER_SECRET = 'O8oHQ3Yn2KCIUDnlMv7MmbKOZP82qpY43ITMh5kQmE'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token,
         oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                           CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
    def doTwitterAuth(self, consumer_key, consumer_secret):
        (oauth_token, oauth_token_secret) = self._redis.mget(
            ['oauth_token', 'oauth_token_secret'])
        if not oauth_token and not oauth_token_secret:
            try:
                (oauth_token,
                 oauth_token_secret) = oauth_dance('this application',
                                                   consumer_key,
                                                   consumer_secret)
                self._redis.mset({
                    'oauth_token': oauth_token,
                    'oauth_token_secret': oauth_token_secret
                })
            except twitter.api.TwitterHTTPError, e:

                # probably an invalid pin

                print 'Unable to perform authentication with OAuth. Aborting'
                raise e
Пример #48
0
def twittersetup():
    if not os.path.isfile('../auth/twitter_app.dat'):
        try:
            appfile = open('../auth/twitter_app.dat', 'w')
            appfile.write("#App name\n")
            appname = raw_input("Enter twitter app name: ")
            appfile.write(appname + '\n')
            appfile.write("#Consumer key\n")
            appconsumer = raw_input("Enter twitter app consumer key: ")
            appfile.write(appconsumer + '\n')
            appfile.write("#Consumer Secret\n")
            appsecret = raw_input("Enter twitter app secret key: ")
            appfile.write(appsecret + '\n')
        except:
            appfile.close()
            print "There was an issue creating the twitter app auth data!!"
            exit()
        finally:
            appfile.flush()
            os.fsync(appfile)
            appfile.close()
    try:
        tappfile = open('../auth/' + 'twitter_app.dat', 'r')
        tappline = tappfile.readlines()
        APP_NAME = tappline[1].rstrip()
        CONSUMER_KEY = tappline[3].rstrip()
        CONSUMER_SECRET = tappline[5].rstrip()
        tappfile.close()
    except:
        exit("Could not read app data file for twitter")

    #file that Oauth data is stored
    TOKEN_FILE = '../auth/' + 'token.txt'
    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token,
         oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                           CONSUMER_SECRET)
        print e.errno
        print e
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #49
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = ''
    CONSUMER_KEY = ''
    CONSUMER_SECRET = ''
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #50
0
def login():
    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'bigrams'
    CONSUMER_KEY = 'pqVYCCTqqDq3WSrwuAaesw'
    CONSUMER_SECRET = 'kvG6OTTvYt6j1rXS34083u9vS0skTSbOCsVImGRWU'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token,
         oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                           CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = ''
    CONSUMER_KEY = 'SKxOLVcsxlPN68V3g2hAA'
    CONSUMER_SECRET = 'jBc0MUUNebHiIEkkraM7IruUyoSY2OZZyZ7eW6qqYw'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #52
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'Photography'
    CONSUMER_KEY = 'fFRVfkuoNyafZglDwDGKpWF1o'
    CONSUMER_SECRET = 'lRMw1avbxoKF13eJ0CeF9WYC6jqMga4310mz6O3uyBQdOUDYkC'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Пример #53
0
def login(app_name=APP_NAME,
                consumer_key=CONSUMER_KEY, 
                consumer_secret=CONSUMER_SECRET, 
                token_file='out/twitter.oauth'):

    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError as e:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,
                consumer_secret)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(token_file, access_token, access_token_secret)

        print ( sys.stderr, "OAuth Success. Token file stored to", token_file)

    return twitter.Twitter(auth=twitter.oauth.OAuth(access_token, access_token_secret,
                           consumer_key, consumer_secret))
Пример #54
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'Experiment1'
    CONSUMER_KEY = 'UkmiRFjbevouUfXh36sVg'
    CONSUMER_SECRET = '7bMMc3nBhHI7JjIMep3Xf7Dkl6w8ImIH7WsskgogY'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token,
         oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                           CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
    tso = TwitterSearchOrder()  # create a TwitterSearchOrder object
    print sys.argv[1]
    tso.setKeywords([
        sys.argv[1]
    ])  # let's define all words we would like to have a look for
    tso.setLanguage('en')  # we want to see German tweets only
    tso.setCount(7)  # please dear Mr Twitter, only give us 7 results per page
    tso.setIncludeEntities(
        False)  # and don't give us all those entity information

    # it's about time to create a TwitterSearch object with our secret tokens
    CONSUMER_KEY = 'SKxOLVcsxlPN68V3g2hAA'
    CONSUMER_SECRET = 'jBc0MUUNebHiIEkkraM7IruUyoSY2OZZyZ7eW6qqYw'
    TOKEN_FILE = 'out/twitter.oauth'
    APP_NAME = ''
    (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                                    CONSUMER_SECRET)
    #print oauth_token
    ts = TwitterSearch(consumer_key=CONSUMER_KEY,
                       consumer_secret=CONSUMER_SECRET,
                       access_token=oauth_token,
                       access_token_secret=oauth_token_secret)
    tweets = []

    for tweet in ts.searchTweetsIterable(
            tso):  # this is where the fun actually starts :)
        #print tweet['text']
        txt = tweet['text']
        words = txt.split()
        #print txt
        #print words[0]
        if (words[0] != "RT"):
Пример #56
0
import sys
import time
import cPickle
import twitter

from twitter.oauth_dance import oauth_dance

consumer_key = 'ppHAC64cJGBBlwIx9ES4fw'
consumer_secret = 'P6DfN32vTZDkSZfglYryXWStT3xJaOKaRUz8SszHQ'
SCREEN_NAME = sys.argv[1]
friends_limit = 10000
(oauth_token, oauth_token_secret) = oauth_dance('MiningTheSocialWeb',
                                                consumer_key, consumer_secret)
t = twitter.Twitter(domain='api.twitter.com',
                    api_version='1',
                    auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
                                             consumer_key, consumer_secret))
ids = []
wait_period = 2  # secs
cursor = -1
while cursor != 0:
    if wait_period > 3600:  # 1 hour
        print 'Too many retries. Saving partial data to disk and exiting'
        f = file('%s.followers_ids' % str(cursor), 'wb')
        cPickle.dump(ids, f)
        f.close()
        exit()

    try:
        response = t.followers.ids(screen_name=SCREEN_NAME, cursor=cursor)
        ids.extend(response['ids'])
import time
import cPickle
import twitter
from twitter.oauth_dance import oauth_dance

SCREEN_NAME = sys.argv[1]

# Go to http://twitter.com/apps/new to create an app
# to get the consumer key/secret

CONSUMER_KEY = sys.argv[2]
CONSUMER_SECRET = sys.argv[3]

friends_limit = 10000

(oauth_token, oauth_token_secret) = oauth_dance('MiningTheSocialWeb',
                                                CONSUMER_KEY, CONSUMER_SECRET)
t = twitter.Twitter(domain='api.twitter.com',
                    api_version='1',
                    auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
                                             CONSUMER_KEY, CONSUMER_SECRET))

ids = []
wait_period = 2  # secs
cursor = -1

while cursor != 0:
    if wait_period > 3600:  # 1 hour
        print >> sys.stderr, \
            'Too many retries. Saving partial data to disk and exiting'
        f = file('%s.friend_ids' % str(cursor), 'wb')
        cPickle.dump(ids, f)
Пример #58
0
import twitter
from twitter.oauth_dance import oauth_dance
import json
import os
import pprint

#import webbrowser

SCREEN_NAME = "marcgibert"
CONSUMER_KEY = "GV0LKJYkEI1Py2oJ0vbITQ" # consumer key
CONSUMER_SECRET = "bKNnKLNn1i5nTP9rnqj3OK5SGHx5PHF4m2hekLe28" # consumer secret

MY_TWITTER_CREDS = os.path.expanduser('~/.my_app_credentials')
if not os.path.exists(MY_TWITTER_CREDS):
    oauth_dance("MGSmartLists", CONSUMER_KEY, CONSUMER_SECRET,
                MY_TWITTER_CREDS)

oauth_token, oauth_secret = twitter.read_token_file(MY_TWITTER_CREDS)

#(oauth_token, oauth_token_secret) = oauth_dance('MGSmartLists',
#        CONSUMER_KEY, CONSUMER_SECRET)

#t = twitter.Twitter(domain='api.twitter.com', api_version='1.1',
#                    auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
#                    CONSUMER_KEY, CONSUMER_SECRET))

t = twitter.Twitter(auth=twitter.OAuth(
    oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))


#twitterConnect = twitter.Twitter(auth=twitter.oauth.OAuth('', '', app_key, app_secret), format='')
Пример #59
0
import twitter
import json
import sys
import time
import cPickle
from twitter.oauth_dance import oauth_dance

consumer_key = 'ppHAC64cJGBBlwIx9ES4fw'
consumer_secret = 'P6DfN32vTZDkSZfglYryXWStT3xJaOKaRUz8SszHQ'
SCREEN_NAME = 'jcukier'
friends_limit = 100000
(oauth_token, oauth_token_secret) = oauth_dance('jcukier', consumer_key, consumer_secret)
t = twitter.Twitter(domain='api.twitter.com', api_version='1',auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,consumer_key, consumer_secret))