- Subscribe and get the new articles every now and then directly in your reader — I recommend using Google Reader
Display Twitter timeline in Expression Engine - Part 2
written by Marek Foss
Last time I explained how to display your Twitter timeline in Expression Engine (EE) using a simple plugin. Today, I will show how to achieve the same and even more using Twitter timeline feed. This approach gives a bit more flexibility and some advantages over the method described in Part 1. We use it on ProcessOne website to push our CEO’s latest tweets.
We will be using Andrew Weaver’s FeedGrab plugin — it allows you to extract data from an RSS feed and insert it into a weblog. The keyword here is weblog. If you don’t realize the benefits yet, let me give you a hint — search. Yes, with this approach you will be able to make all your tweets searchable, just as you make your weblog posts searchable.
The second advantage is that you don’t need to give your Twitter username and password explicitly in the EE template (as you had to in Part 1). You just monitor your feed (or any other, in fact). Here’s how you implement that.
First, you need a custom field group to store your tweets. Create one in Admin > Weblog Administration > Custom Weblog Fields > Create a New Weblog Field Group. Let’s say you call it Twitter Field Group. Select Add/Edit Custom Fields to modify this new group. You have to create 2 fields — one for Twitter URL (say twitter_url), and one for Twitter message (say twitter_text). In both cases be sure that you the Field Type is of Text Input and the text formatting is set to None. In case of the tweet text, be sure to turn on field searching.

Next, you need to create a new weblog (Admin > Weblog Administration > Weblog Management > Create a New Weblog). Edit group preferences and set the default Field Group to the Twitter one you have just created. After creating the new weblog, note its ID, we’ll need that later on.

Finally, you need to create a separate, empty template. It’s good practice to have it in a separate template group too. For example, let’s make a group named feeds with an empty template twitter. In that template, just put the FeedGrab code:
{exp:feedgrab url="http://twitter.com/statuses/user_timeline/16728857.atom"
weblog="2"
author="1"
title="title"
date="published"
use="link|title"
fields="twitter_url|twitter_text"
unique="twitter_url"
}
The url is the feed location. The use variable tells FeedGrab what to take from the feed (in our case, the Twitter link and the title, which is the actual tweet), while fields show where to push that data accordingly. The unique element here is obviously the tweet URL.
When you go to http://yoursite/feeds/twitter/ you should invoke FeedGrab, and the tweets should appear as separate posts in your recently created weblog. All you need to do now is to set a cron job that periodically visits the above URL to update the weblog contents. Then, just display that weblog wherever you wish on your page, just as any other weblog.


