|
12 | 12 | All text above must be included in any redistribution. |
13 | 13 | """ |
14 | 14 |
|
| 15 | +#pylint:disable=invalid-name |
15 | 16 | import time |
16 | | -import random |
17 | | -import board |
18 | | -import busio |
19 | 17 | import binascii |
20 | 18 | import json |
| 19 | +import board |
| 20 | +import busio |
21 | 21 | from adafruit_pyportal import PyPortal |
22 | | -from adafruit_bitmap_font import bitmap_font |
23 | | -from adafruit_display_text.label import Label |
24 | 22 | from digitalio import DigitalInOut |
25 | 23 | from adafruit_esp32spi import adafruit_esp32spi |
26 | 24 | import adafruit_esp32spi.adafruit_esp32spi_requests as requests |
@@ -70,8 +68,8 @@ def get_bearer_token(): |
70 | 68 | raw_key = secrets['twitter_api_key'] + ':' + secrets['twitter_secret_key'] |
71 | 69 | encoded_key = binascii.b2a_base64(bytes(raw_key, 'utf8')) |
72 | 70 | string_key = bytes.decode(encoded_key) |
73 | | - headers= {'Authorization': 'Basic ' + string_key, |
74 | | - 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'} |
| 71 | + headers = {'Authorization': 'Basic ' + string_key, |
| 72 | + 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'} |
75 | 73 | response = requests.post('https://api.twitter.com/oauth2/token', |
76 | 74 | headers=headers, |
77 | 75 | data='grant_type=client_credentials') |
@@ -119,9 +117,10 @@ def get_bearer_token(): |
119 | 117 |
|
120 | 118 | headers = {'Authorization': 'Bearer ' + bearer_token} |
121 | 119 |
|
| 120 | +url = 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=1&screen_name=' + username |
122 | 121 | while True: |
123 | 122 | logger.debug('fetching latest tweet from @%s', username) |
124 | | - response = requests.get('https://api.twitter.com/1.1/statuses/user_timeline.json?count=1&screen_name=' + username, |
| 123 | + response = requests.get(url, |
125 | 124 | headers=headers) |
126 | 125 | if response.status_code != 200: |
127 | 126 | logger.error('Tweet fetch status: %d', response.status_code) |
|
0 commit comments