diff --git a/index.html b/index.html index c91fa03..14b6279 100644 --- a/index.html +++ b/index.html @@ -4,12 +4,12 @@ - - - + + + - + @@ -20,7 +20,7 @@ - Nice page + Pages by Rybak @@ -49,6 +49,8 @@

Coin


JS: On-Power-Off schedule
+ JS: Twitter poll api +
diff --git a/twitter-poll-api/css/style.css b/twitter-poll-api/css/style.css new file mode 100644 index 0000000..375b113 --- /dev/null +++ b/twitter-poll-api/css/style.css @@ -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; +} \ No newline at end of file diff --git a/twitter-poll-api/index.html b/twitter-poll-api/index.html new file mode 100644 index 0000000..8d19bb0 --- /dev/null +++ b/twitter-poll-api/index.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + Twitter poll api + + + + +
+

Twitter(X) votes API

+ +
+
+ + + diff --git a/twitter-poll-api/js/script.js b/twitter-poll-api/js/script.js new file mode 100644 index 0000000..2d3c18c --- /dev/null +++ b/twitter-poll-api/js/script.js @@ -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" + } + ] +} +} \ No newline at end of file