July 2017
Beginner to intermediate
312 pages
7h 27m
English
Firstly, we include all necessary libraries. We have added the json library to be able to parse easily the outputs of the Twitter API and urllib.parse, which encodes a query string into a proper request URL:
import requests from requests_oauthlib import OAuth1 import json from urllib.parse import urlparse
In the first place, we define parameters that will be used to establish connections with the Twitter API and we create an OAuth client connection:
params = {
'app_key':'YOUR_APP_KEY', 'app_secret':'YOUR_APP_SECRET', 'oauth_token':'USER_OAUTH_TOKEN', 'oauth_token_secret':'USER_OAUTH_TOKEN_SECRET'
}
auth = OAuth1(
params['app_key'], params['app_secret'], params['oauth_token'], params['oauth_token_secret'] ...Read now
Unlock full access