Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何获取StockTwit API的访问令牌密钥?_Python_Api_Authentication_Oauth_Stocktwits - Fatal编程技术网

Python 如何获取StockTwit API的访问令牌密钥?

Python 如何获取StockTwit API的访问令牌密钥?,python,api,authentication,oauth,stocktwits,Python,Api,Authentication,Oauth,Stocktwits,我已经获得了使用者密钥、使用者机密和访问令牌,但我不知道如何获取访问令牌机密。这个代码有效,但我只需要访问令牌密码。提前谢谢 #!/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

我已经获得了使用者密钥、使用者机密和访问令牌,但我不知道如何获取访问令牌机密。这个代码有效,但我只需要访问令牌密码。提前谢谢

#!/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'])

StockTwits不提供
访问令牌\u密码
。一旦您拥有一个
访问令牌
,该令牌就可以用于对API的所有请求。您希望看到您的OAuthHandler类只允许设置一个
访问\u令牌
。应该这样