当前位置: 首页>>代码示例>>Python>>正文


Python oauth_dance.oauth_dance函数代码示例

本文整理汇总了Python中twitter.oauth_dance.oauth_dance函数的典型用法代码示例。如果您正苦于以下问题:Python oauth_dance函数的具体用法?Python oauth_dance怎么用?Python oauth_dance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了oauth_dance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_twitter

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
开发者ID:ibread,项目名称:ibread,代码行数:27,代码来源:report.py

示例2: __init__

    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
开发者ID:aquarion,项目名称:lampstand,代码行数:34,代码来源:lowflying.py

示例3: main

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()    
开发者ID:WSDOT,项目名称:wsdot-twitter-tools,代码行数:11,代码来源:seattle_incidents.py

示例4: main

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()    
开发者ID:WSDOT,项目名称:wsdot-twitter-tools,代码行数:11,代码来源:srtmc_alerts.py

示例5: main

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)
开发者ID:WSDOT,项目名称:wsdot-twitter-tools,代码行数:12,代码来源:ferry_alerts.py

示例6: __init__

    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')
开发者ID:scraperdragon,项目名称:lampstand,代码行数:51,代码来源:weblink.py

示例7: __init__

 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']
开发者ID:bbolli,项目名称:twitter-monday,代码行数:15,代码来源:monday.py

示例8: main

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")
开发者ID:iandees,项目名称:twitter-stream-archiver,代码行数:48,代码来源:twitter_stream.py

示例9: login

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)
开发者ID:weikengary,项目名称:CS4242AS3,代码行数:26,代码来源:twitter__login.py

示例10: generate_following_token

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
开发者ID:KeithYue,项目名称:QA-spider,代码行数:7,代码来源:generate_auth_tokens.py

示例11: generate_archiever_token

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
开发者ID:KeithYue,项目名称:QA-spider,代码行数:7,代码来源:generate_auth_tokens.py

示例12: initialize

 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)
开发者ID:skitazaki,项目名称:oauth-client,代码行数:7,代码来源:twitter_wrap.py

示例13: login

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)
开发者ID:jinpeng,项目名称:TwitterHavest,代码行数:29,代码来源:twitter__login.py

示例14: login_and_get_twitter

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))
开发者ID:Baphomet1105,项目名称:twitMiner-tweet-collector.py,代码行数:25,代码来源:login.py

示例15: handle

 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)
     )
开发者ID:zauberpony,项目名称:django-tweet-saved,代码行数:8,代码来源:tweet_oauth.py


注:本文中的twitter.oauth_dance.oauth_dance函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。