Blog

Dev tip : Embed a Twitter timeline on a Website without OAuth

To embed a twitter timeline or a tweet feed on a website, you have 2 choices : use the widget provided from Twitter or use their 1.1 API.

Using the 1.1 API

To use Twitter 1.1 REST API, you’ll need an OAuth or an app token. This API very complete and you can do whatever you want with the data you get.
The worst part is, you are limited on number of queries per time.

All info about available data : https://dev.twitter.com/docs/api/1.1

Each query has a rate limiting, divided into 15 minutes intervals : https://dev.twitter.com/docs/rate-limiting/1.1

It’s easy to use the API to display tweets on a website with AJAX. But as it’s limited, if there are to many visitors, your queries will be rejected.

The best way would be to get tweets on server side every 5 minutes, save it into the DB so you won’t query twitter api each time the page is loaded.

Using the Twitter widget

This widget is really easy to use. Twitter even has an assistant to help you set it up : https://twitter.com/settings/widgets/new

The Twitter WidgetBut this widget is quite limited. Its main drawback is that you can’t customize the way tweets are displayed. You can always use CSS but it’s limited and it also has a few customization options but nothing really advanced.

More info there : https://dev.twitter.com/docs/embedded-timelines

Cheating the Twitter widget

To avoid REST 1.1 API and its limitations, Jason Mayes has created a JS script to get tweets from the widget. So you avoid OAuth and limited queries and you get only tweet data as JSON so you can process it the way you want. Very handy !

You can get more info on his website: http://jasonmayes.com/projects/twitterApi/

Comments

Have a Project for Us?

Request a Proposal