Access to the Stream Streaming API without an application

I am writing a Twitter program for a small market mood that I make for fun at Pyhon using the Tweepy library. However, my limited knowledge of API access and much more make most of the Twitter API documentation a little cryptic. I would like to know a few things, and if this is not the right place for these questions, please let me know so that I can post them elsewhere:

1) I do not have the application that I am writing. Is it possible to access the Streaming API without it? If so, how can I apply for a consumer and token access keys so that I can access the feed with Oauth2?

2) Is it possible to simply access my own Twitter channel with all my followers, and then follow a ton of people who I think will have relevant market information?

I currently have a quick program that I found on the Internet below, but obviously I am currently getting "Error: 401" because I do not have a client key or access key:

import tweepy import oauth2 consumer_key = '' consumer_secret = '' access_token_key = '' access_token_secret = '' auth1 = tweepy.OAuthHandler(consumer_key, consumer_secret) auth1.set_access_token(access_token_key, access_token_secret) class StreamListener(tweepy.StreamListener): def on_status(self, tweet): print 'Ran on_status' def on_error(self, status_code): print 'Error: ' + str(status_code) return False def on_data(self, data): print 'Ok, this is actually running' l = StreamListener() streamer = tweepy.Stream(auth=auth1, listener=l) setTerms = ['twitter'] streamer.filter(track=setTerms) 

Any help is greatly appreciated - thanks.

EDIT: Should I just create a dummy application so that I can access the API?

+4
source share
2 answers

You can just create an application just for yourself to access the API: https://dev.twitter.com/apps

1) With tweepy you can also use basic authentication:

 auth = tweepy.BasicAuthHandler(username, password) api = tweepy.API(auth) 

2) Yes, you can use api to request your feed and feed of other users: for example, API.user_timeline() , API.home_timeline() , API.followers()

Find the tweepy API link for the functions you want to use: http://pythonhosted.org/tweepy/html/api.html

+4
source
  • Registering the application on Twitter takes no more than 1 minute. It provides [consumer / access] [key / secret], which you just need to copy and paste into the code:

    Register Twitter application .

  • Basically, all visible data on the Twitter web interface can be retrieved using some Twitter API methods, so it seems very doable.

+2
source

Source: https://habr.com/ru/post/1481756/


All Articles