Skip to content
Snippets Groups Projects
Commit 8a64e86f authored by dnns01's avatar dnns01
Browse files

Minor changes

parent ea0b9ee4
No related branches found
No related tags found
No related merge requests found
from django.shortcuts import render
from django.http import JsonResponse
import requests
import os
# Create your views here.
......@@ -9,16 +10,13 @@ def guestbook(request):
response = requests.get(
"https://api.twitter.com/2/tweets/search/recent?query=%23StrolchGäBu%20%23StrolchGast&user.fields=name&expansions=author_id&max_results=100&tweet.fields=created_at",
headers={
'Authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAADkVLgEAAAAAbQxmw7UXlTMYdcd%2BrcWQ7T8lZlc%3DQjRkgsq3d4XeIXk2vZzagBLuBB5UUlTKwBl8Uz0XafzAfVnAxc'
'Authorization': f'Bearer {os.getenv("TWITTER_TOKEN")}'
})
response_json = response.json()
users = {user["id"]: user["name"] for user in response_json["includes"]["users"]}
for tweet in response_json["data"]:
print(tweet)
tweets[tweet["id"]] = {"author" : users[tweet["author_id"]], "text": tweet["text"], "created_at": tweet["created_at"]}
print(tweets)
return JsonResponse(tweets)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment