【问题标题】:How to get access token secret for StockTwit API?如何获取 StockTwit API 的访问令牌秘密?
【发布时间】:2017-09-30 19:05:58
【问题描述】:

我已经获得了消费者密钥、消费者秘密和访问令牌,但我不知道如何获取访问令牌秘密。此代码有效,但我只需要访问令牌密码。提前致谢!

#!/usr/bin/python
#Import the necessary methods from tweepy library
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream

#Variables that contains the user credentials to access stocktwits API
consumer_key = "something"
consumer_secret = "something"
access_token = "something"
#access_token_secret = ""

#This is a basic listener that just prints received tweets to stdout.
class StdOutListener(StreamListener):

    def on_data(self, data):
        print data
        return True

    def on_error(self, status):
        print status


if __name__ == '__main__':

    #This handles Twitter authetification and the connection to Twitter Streaming API
    l = StdOutListener()
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    stream = Stream(auth, l)

    #This line filter Twitter Streams to capture data by the keywords
    stream.filter(track=['Hillary Clinton', '#Hillary', 'Donald Trump', '#Trump'])

【问题讨论】:

    标签: python api authentication oauth stocktwits


    【解决方案1】:

    StockTwits 不提供access_token_secret。一旦您有了access token,该令牌就可以用于对 API 的所有请求。你会想看看你的 OAuthHandler 类只允许设置一个access_token。应该的。

    【讨论】:

      猜你喜欢
      • 2012-10-27
      • 2012-04-28
      • 2012-12-29
      • 2011-12-31
      • 2013-04-17
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多