-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
outline: none; | ||
box-sizing: border-box; | ||
} | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #1f2431; | ||
color: #90a1b9; | ||
padding: 40px; | ||
font-size: 20px; | ||
} | ||
#result { | ||
background-color: #1b1b1b; | ||
border: 2px solid #41454f; | ||
border-radius: 4px; | ||
padding: 24px; | ||
} | ||
.btn { | ||
border: 2px solid #dd8822; | ||
background-color: #ff9f2f; | ||
color: #fff; | ||
padding: 10px 20px; | ||
border-radius: 4px; | ||
font-size: 20px; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<link rel='icon' href='favicon.ico' type='image/x-icon'/ > | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<meta name="author" content="RybakV" /> | ||
<meta name="description" content="Twitter poll api fetching votes"> | ||
<meta name="keywords" content="Rybak, JS, Twitter, API"> | ||
|
||
<!-- OG image for nice social networks sharing --> | ||
<meta property="og:title" content="Twitter poll api"> | ||
<meta property="og:description" content="Twitter poll api fetching votes"> | ||
<!--<meta property="og:image" content="http://rybak.github.io/img/coin.gif">--> | ||
<meta property="og:url" content="http://rybak.github.io/"> | ||
|
||
<meta name="twitter:title" content="Twitter poll api"> | ||
<meta name="twitter:description" content="Twitter poll api fetching votes"> | ||
<!--<meta name="twitter:image" content="http://rybak.github.io/img/coin.gif">--> | ||
<!--<meta name="twitter:card" content="summary_large_image">--> | ||
|
||
<!-- Document title --> | ||
<title>Twitter poll api</title> | ||
<!-- Stylesheets & Fonts --> | ||
<link href="./css/style.css" rel="stylesheet"> | ||
|
||
<body> | ||
<div class="container text-center"> | ||
<h1>Twitter(X) votes API</h1> | ||
<button class="btn" id="start">Start</button> | ||
<div id="result"></div> | ||
</div> | ||
<script src="./js/script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//curl --request GET 'https://api.twitter.com/2/tweets?ids=1199786642791452673&expansions=attachments.poll_ids&poll.fields=duration_minutes,end_datetime,id,options,voting_status' --header 'Authorization: Bearer $BEARER_TOKEN' | ||
const startBtn = document.querySelector('#start'); | ||
const resultBox = document.querySelector('#result'); | ||
startBtn.addEventListener('click', startApp); | ||
|
||
function startApp(){ | ||
fetch('https://api.twitter.com/2/tweets?ids=1749817159872831578&expansions=attachments.poll_ids&poll.fields=duration_minutes,end_datetime,id,options,voting_status') | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
resultBox.innerText = data; | ||
}); | ||
} | ||
|
||
|
||
const exampleResponse = { | ||
"data": [ | ||
{ | ||
"text": "C#", | ||
"id": "1199786642791452673", | ||
"attachments": { | ||
"poll_ids": [ | ||
"1199786642468413448" | ||
] | ||
} | ||
} | ||
], | ||
"includes": { | ||
"polls": [ | ||
{ | ||
"id": "1199786642468413448", | ||
"voting_status": "closed", | ||
"duration_minutes": 1440, | ||
"options": [ | ||
{ | ||
"position": 1, | ||
"label": "“C Sharp”", | ||
"votes": 795 | ||
}, | ||
{ | ||
"position": 2, | ||
"label": "“C Hashtag”", | ||
"votes": 156 | ||
} | ||
], | ||
"end_datetime": "2019-11-28T20:26:41.000Z" | ||
} | ||
] | ||
} | ||
} |