Fetches your latest tweets
Show your latest tweet or tweets on your website.
Twitter offers two options to show your twitterfetch on your website:
They are fully supported by Twitter and might be the best solution for you.
- Limited layout possibilities (widget).
- Cookies are send to Twitter, which, without warning, might be illegal in your jurisdiction (widget).
- Page load (widget).
- Needs server side scripting (api).
TwitterFetch uses unsupported Twitter functionality, so there's no guarantee of continuity.
Start by downloading twitterfetch.js to you server and including it in your web page.
In your HTML, make sure you have a place to show the tweets:
Now, use twitterFetch to fetch the tweets and show the first one:
But don't use the widget id 345615146724495360, that belongs to my @edwinmdev Twitter account.
How to make your own widget id?
Create a Twitter widget and look at the generated code. You'll find data-widget-id="..." with the number you can use.
The twitterFetch fetch function takes three parameters:
The widget id you get when creating a widget, see above.
An object literal with several options:
images (boolean): when false, prevents loading images that are not needed (default: false).
plaintext (boolean): when false, encodes some entities to make the text safe for HTML (default: false).
hyperlinks (boolean): when true, turns urls and Twitter @usernames into hyperlinks (default: true).
images: falseplaintext: true
The function that is called back with one argument containing an array with tweets.
TwitterFetch is copyright 2016 Edwin Martin and MIT licensed.