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


Python twitter.oauth_dance函数代码示例

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


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

示例1: twitter_init

def twitter_init():
    try:
        config_settings["twitter_creds_file"] = os.path.abspath(
            os.path.expanduser(config_settings["twitter_creds_file"])
        )
        if not os.path.exists(config_settings["twitter_creds_file"]):
            twitter.oauth_dance(
                "fuzzer_stats",
                config_settings["twitter_consumer_key"],
                config_settings["twitter_consumer_secret"],
                config_settings["twitter_creds_file"],
            )
        oauth_token, oauth_secret = twitter.read_token_file(config_settings["twitter_creds_file"])
        twitter_instance = twitter.Twitter(
            auth=twitter.OAuth(
                oauth_token,
                oauth_secret,
                config_settings["twitter_consumer_key"],
                config_settings["twitter_consumer_secret"],
            )
        )
        return twitter_instance
    except (twitter.TwitterHTTPError, URLError):
        print_err("Network error, twitter login failed! Check your connection!")
        sys.exit(1)
开发者ID:zined,项目名称:afl-utils,代码行数:25,代码来源:afl_stats.py

示例2: tweet

def tweet(entry, conf, dryrun=False):
    """Send a tweet with the title, link and tags from an entry. The first time you
    need to authorize Acrylamid but than it works without any interaction."""

    key = "6k00FRe6w4SZfqEzzzyZVA"
    secret = "fzRfQcqQX4gcZziyLeoI5wSbnFb7GGj2oEh10hnjPUo"

    creds = os.path.expanduser('~/.twitter_oauth')
    if not os.path.exists(creds):
        twitter.oauth_dance("Acrylamid", key, secret, creds)

    oauth_token, oauth_token_secret = twitter.read_token_file(creds)
    t = twitter.Twitter(auth=twitter.OAuth(oauth_token, oauth_token_secret, key, secret))

    tweet = u"New Blog Entry: {0} {1} {2}".format(entry.title,
        helpers.joinurl(conf['www_root'], entry.permalink),
        ' '.join([u'#' + helpers.safeslug(tag) for tag in entry.tags]))

    print('     ', bold(blue("tweet ")), end='')
    print('\n'.join(wrap(tweet.encode('utf8'), subsequent_indent=' '*13)))

    if not dryrun:
        try:
            t.statuses.update(status=tweet.encode('utf8'))
        except twitter.api.TwitterError as e:
            try:
                log.warn("%s" % json.loads(e.response_data)['error'])
            except (ValueError, TypeError):
                log.warn("Twitter: something went wrong...")
开发者ID:naufraghi,项目名称:acrylamid,代码行数:29,代码来源:ping.py

示例3: __init__

 def __init__ (self, ckey, csecret, token_file, user_name=""):
     if not os.path.exists(token_file):
         twitter.oauth_dance(user_name, ckey, csecret, token_file)
     
     self.oauth_token, self.oauth_token_secret = twitter.read_token_file(token_file)
     
     self.handle = twitter.Twitter(
                   auth=twitter.OAuth(self.oauth_token, self.oauth_token_secret, 
                                      ckey, csecret))
开发者ID:braynebuddy,项目名称:PyBrayne,代码行数:9,代码来源:iTwitter.py

示例4: setup_twitter

def setup_twitter(consumer_key, consumer_secret, credentials_file):
    # Authenticate to twitter using OAuth
    if not os.path.exists(credentials_file):
        twitter.oauth_dance("Tweet to Door Sign Converter", consumer_key,
                            consumer_secret, credentials_file)

    oauth_token, oauth_secret = twitter.read_token_file(credentials_file)
    t = twitter.Twitter(auth=twitter.OAuth(
            oauth_token, oauth_secret, consumer_key, consumer_secret))

    return t
开发者ID:mikerenfro,项目名称:tweetable-office-door-sign,代码行数:11,代码来源:doorsign.py

示例5: oauth_login

    def oauth_login(consumer_key, consumer_secret, access_token, access_token_secret):
        if not access_token or not access_token_secret:
            oauth_file = './twitter_oauth'
            if not os.path.exists(oauth_file):
                twitter.oauth_dance("App", consumer_key, consumer_secret, oauth_file)
            access_token, access_token_secret = twitter.read_token_file(oauth_file)

        auth = twitter.oauth.OAuth(access_token, access_token_secret,
                                   consumer_key, consumer_secret)

        return twitter.Twitter(auth=auth)
开发者ID:Bulletninja,项目名称:twitter-wordcloud-bot,代码行数:11,代码来源:twitterapi.py

示例6: get_twitter

def get_twitter():
    MY_TWITTER_CREDS = os.path.join(os.path.dirname(__file__), '.clocktweeter_credentials')
    if not os.path.exists(MY_TWITTER_CREDS):
        twitter.oauth_dance("Trinity clock tweeter", CONSUMER_KEY,
                            CONSUMER_SECRET, MY_TWITTER_CREDS)

    oauth_token, oauth_secret = twitter.read_token_file(MY_TWITTER_CREDS)

    t = twitter.Twitter(auth=twitter.OAuth(
        oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))
    return t
开发者ID:ricklupton,项目名称:clocktweeter,代码行数:11,代码来源:clocktweeter.py

示例7: get_twitter_client

def get_twitter_client():
    CONSUMER_KEY = 'mDW8dNVXrioYiSjse9hneaDGy'
    CONSUMER_SECRET = 'jg0A2CcHaVSBWfsOqhgABUxQoZUx7sstEk9NSVUbVphkGJr1Zb'

    oauth_filename = 'credentials'
    if not os.path.exists(oauth_filename):
        twitter.oauth_dance("ruukku", CONSUMER_KEY, CONSUMER_SECRET, oauth_filename)

    oauth_token, oauth_secret = twitter.read_token_file(oauth_filename)

    auth = twitter.OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET)
    return twitter.Twitter(auth=auth)
开发者ID:jokallun,项目名称:flow-talks,代码行数:12,代码来源:tweets.py

示例8: tweet

    def tweet(self, app_name, version):
        MY_TWITTER_CREDS = os.path.expanduser('~/.twitter_oauth')
        CONSUMER_KEY, CONSUMER_SECRET = self.load_app_keys()

        if not os.path.exists(MY_TWITTER_CREDS):
            twitter.oauth_dance("autopkgsays", CONSUMER_KEY, CONSUMER_SECRET,
                        MY_TWITTER_CREDS)
        oauth_token, oauth_secret = twitter.read_token_file(MY_TWITTER_CREDS)
        twitter_instance = twitter.Twitter(auth=twitter.OAuth(
            oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))
        # Now work with Twitter
        twitter_instance.statuses.update(status="%s version %s has been released" % (app_name, version))
开发者ID:natewalck,项目名称:recipes,代码行数:12,代码来源:TweetChanges.py

示例9: __init__

    def __init__(self):
        if not file.exists(OAUTH_TOKEN_FILE):
            oauth_dance("mpvshots",
                        CONSUMER_KEY,
                        CONSUMER_SECRET,
                        OAUTH_TOKEN_FILE)

        oauth_token, oauth_secret = read_token_file(OAUTH_TOKEN_FILE)

        oauth = OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET)
        self._twitter = Twitter(auth=oauth)
        self._upload = Twitter(domain="upload.twitter.com", auth=oauth)
开发者ID:slowpoketail,项目名称:mpvshots,代码行数:12,代码来源:twitter.py

示例10: connect

def connect():
    global t

    # Twitter credentials
    CONSUMER_KEY = "JEdRRoDsfwzCtupkir4ivQ"
    CONSUMER_SECRET = "PAbSSmzQxbcnkYYH2vQpKVSq2yPARfKm0Yl6DrLc"

    MY_TWITTER_CREDS = os.path.expanduser("~/.my_app_credentials")
    if not os.path.exists(MY_TWITTER_CREDS):
        oauth_dance("Semeval sentiment analysis", CONSUMER_KEY, CONSUMER_SECRET, MY_TWITTER_CREDS)
    oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)
    t = Twitter(auth=OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))
开发者ID:smartinsightsfromdata,项目名称:SemEval-2015,代码行数:12,代码来源:interface_twitter.py

示例11: authenticate

 def authenticate(self):
     """ Authenticates with twitter app and returns a Twitter object. """
     if not os.path.exists(self.TWITTER_CREDS):
         oauth_dance(
                 self.APP_NAME,
                 self.CONSUMER_KEY,
                 self._consumer_secret,
                 self.TWITTER_CREDS
                 )
     oauth_token, oauth_secret = read_token_file(self.TWITTER_CREDS)
     return Twitter(auth=OAuth(
         oauth_token, oauth_secret, self.CONSUMER_KEY, self._consumer_secret
         ))
开发者ID:johnislarry,项目名称:SomnolentTweeters,代码行数:13,代码来源:SomnolentTwitterAPIWrapper.py

示例12: send_twitter

def send_twitter(APP_NAME, CONSUMER_KEY, CONSUMER_SECRET, tweet):
    MY_TWITTER_CREDS = os.path.expanduser('./twitter_id')

    if not os.path.exists(MY_TWITTER_CREDS):
        twitter.oauth_dance(APP_NAME, CONSUMER_KEY,
                            CONSUMER_SECRET, MY_TWITTER_CREDS)
        print(em('saved access token') + 'at' + MY_TWITTER_CREDS)

    oauth_token, oauth_secret = twitter.read_token_file(MY_TWITTER_CREDS)
    tw = twitter.Twitter(auth=twitter.OAuth(oauth_token, oauth_secret,
                                            CONSUMER_KEY, CONSUMER_SECRET))
    tw.statuses.update(status=tweet)
    print('Tweeted.')
开发者ID:cormoran,项目名称:WebSiteUpdateNotifier,代码行数:13,代码来源:website_update_check.py

示例13: __init__

    def __init__(self, connect=True):

        # Offline?
        if connect:
            # Twitter credentials
            CONSUMER_KEY='JEdRRoDsfwzCtupkir4ivQ'
            CONSUMER_SECRET='PAbSSmzQxbcnkYYH2vQpKVSq2yPARfKm0Yl6DrLc'

            MY_TWITTER_CREDS = os.path.expanduser('~/.my_app_credentials')
            if not os.path.exists(MY_TWITTER_CREDS):
                oauth_dance("Semeval sentiment analysis", CONSUMER_KEY, CONSUMER_SECRET, MY_TWITTER_CREDS)
            oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)
            self.t = Twitter(auth=OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))
开发者ID:mikemeding,项目名称:NLP-Project,代码行数:13,代码来源:interface_twitter.py

示例14: __init__

 def __init__(self, autogen=True, markovdb=os.path.expanduser("~/markov"), twcreds=os.path.expanduser("~/.michiov_twitter_credentials"),twappcreds=os.path.expanduser("~/.michiov_twitter_appdata")):
   self.mc = MarkovChain(markovdb)
   self.reload()
   if not os.path.exists(twappcreds):
     print("Lack of app creds")
     sys.exit(1)
   twcons = json.loads(open(twappcreds).read())
   conskey = twcons['key']
   conssec = twcons['secret']
   while not os.path.exists(twcreds):
     twitter.oauth_dance("MPRZ Tech Labs", conskey, conssec, twcreds)
   oauth_token, oauth_secret = twitter.read_token_file(twcreds)
   self.t = twitter.Twitter(auth=twitter.OAuth(oauth_token, oauth_secret, conskey, conssec))
开发者ID:MPRZLabs,项目名称:icarus,代码行数:13,代码来源:reqas.py

示例15: connect_twitter

def connect_twitter():
    """Initialize connection to Twitter"""
    # authenticate
    creds = os.path.expanduser('~/.tweets2sql-oauth')
    CONSUMER_KEY = 'mikYMFxbLhD1TAhaztCshA'
    CONSUMER_SECRET = 'Ys9VHBWLS5fX4cFnDHSVac52fl388JV19yJz1WMss'
    if not os.path.exists(creds):
        twitter.oauth_dance("tweets2sql", CONSUMER_KEY, CONSUMER_SECRET, creds)
    oauth_token, oauth_secret = twitter.read_token_file(creds)
    auth = twitter.OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET)

    # connect
    return twitter.Twitter(domain='api.twitter.com', auth=auth, api_version = '1.1')
开发者ID:az0,项目名称:tweets2sql,代码行数:13,代码来源:tweets2sql.py


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