Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
strolchibot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dnns01
strolchibot
Commits
8a64e86f
Commit
8a64e86f
authored
4 years ago
by
dnns01
Browse files
Options
Downloads
Patches
Plain Diff
Minor changes
parent
ea0b9ee4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
twitter/views.py
+2
-4
2 additions, 4 deletions
twitter/views.py
with
2 additions
and
4 deletions
twitter/views.py
+
2
−
4
View file @
8a64e86f
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment