How can use the twitter API’s to get my timeline and display it in a HTML page? I want to query the API’s using HTML.
The questions I found on Stack Overflow are old and the answers don’t seem to work any more.
Any help would be appreciated.
How can use the twitter API’s to get my timeline and display it in a HTML page? I want to query the API’s using HTML.
The questions I found on Stack Overflow are old and the answers don’t seem to work any more.
Any help would be appreciated.
3
Answers
You can embed your timeline from twitter using this url: https://publish.twitter.com/
Enter your profile url from twitter.
It will generate a code similar to following:
If you copy and paste the above code into your html, it will embed Elon Musk’s twitter timeline.
You can also customize some settings while you’re in the website.
What this code does:
At the time of writing; It basically inserts 2
<script>
tags in the<head>
tag. Also replaces the<a>
tag with a generated<iframe>
with twitter’s own styling for the timeline. So it doesn’t matter what you write in the<a>
tag. Only the href attribute should be your timeline link and you should also keep the twitter-timeline class.As I mentioned in the comments, you can use the script provided by Twitter after going through this tool. It relies on a quite large script (95 kB minified) to load in the timeline with updates, which is what differentiates that from using the API to load data in.
The code provided is quite simplistic, as you just need a “link” that is then swapped out by Twitter’s code.
You can also set some basic customization, such as width, height, and colors from the widget generator.
(I tried making it a snippet, but it fails on Stack Overflow)
Unfortunately, this appears to be the only officially supported way of loading a timeline, short of implementing it with a backend and live updates via the API.
NB: I have personally contacted Twitter with a follow up asking about the possibility of them open-sourcing the widget script. Doing so would allow anyone to remove the polyfills for features widely supported, as well as ship modern code that isn’t transpiled down to ES3. Combined, these efforts would provide a huge savings over the current 95k, but unfortunately I did not receive a response to either email.
You can copy paste the below code to understand how twitter API tool works for showing timelineposts , hashtag data as well as you can see if the user is mentioned in any posts.