Setting up tweepy authentication
In the video, we saw how tweepy can be used to collect Twitter data with the Streaming API. tweepy requires a Twitter API key to authenticate with Twitter.
In this exercise, you will load several objects from tweepy and set up the authentication for the package.
The API keys access_token, access_token_secret, consumer_key, and consumer_secret have already been defined for you.
この演習はコースの一部です
Analyzing Social Media Data in Python
演習の手順
- Import
OAuthHandlerandAPIfrom thetweepymodule. - Pass
consumer_keyandconsumer_secrettoOAuthHandler. - Set the access tokens with
access_tokenandaccess_token_secret. - Pass the
authobject to the API.
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
from ____ import ____
from ____ import ____
# Consumer key authentication
auth = OAuthHandler(____, ____)
# Access key authentication
auth.set_access_token(____, ____)
# Set up the API with the authentication handler
api = API(____)