Seeing sites that feature an up-to-date Twitter feed is becoming pretty standard these days. For a while I was getting a bit annoyed with them. I then figured out what was bugging me - here is a persons / company's professional twitter feed, as showing on the home page of their site and half the tweets are conversational ones between the site owner and someone else.
Of course Twitter is great as a quick, conversational medium, but you don't want that showing on your homepage. If nothing else, your site's visitors will have no context for that conversation and will feel alienated. They can also come across as perhaps a little too informal, and various Retweets, whilst useful, don't really say anything about you yourself.
What you really want on there is the interesting tweets - the links, the opinions, the thoughts, the activity - this is what will communicate your personality, your brand to your site's new users, the visitors that know nothing about you yet.
So that's the problem... what's the solution?Ways to actually implement this had been floating around my head for a while, but more recently, I've also noticed a few other people have also flagged this up.
So I decided to try out what was in my head, see if it would actually work.
First try, no such luckThe first thing I tried was to use a standard Twitter Plugin.
Twitter Search 2 seemed the best one to use - it constantly and dynamically pulls tweets from a users feed and displays them with certain meta info in a page.
The trouble was, the Twitter Search API doesn't allow a great deal of flexibility - you can't filter out @mentions, you can't search for more than 1 feed (Moogaloo being made up of
@moogaloo and
@beamoogaloo).
Back to the drawing board (and what I'd been thinking I'd have to do all along), and I've now cracked it. You can see a rough version here -
http://dev.moogaloo.in-the-safe-hands-of-moogaloo.com/twitter/ - this is just a development site - I'll push this to our main site soon.
Cooking up a recipe of Twitter activityA brief overview then on how it works.
- Pull all your tweets from all your twitter user accounts into EE using Datagrab
- Use the standard Channel Entries tag to display these
- Filter out the tweets you don't want
- Make the tweets look pretty
So, some details.
All good recipes start with a bunch of fresh
ingredients (or addons in this case):
DataGrab Low ReplaceTweetifyCE GravatarAnd the instructions:First you want to create a channel. I created 2 channels, one for each of the twitter accounts to be pulling in, but no reason not to use one channel for all of them - you can separate them out later if needed.
The fields I used were:
- Tweet Text (so its's not limited by the standard title character count)
- Tweet link
- Date timestamp
- Source
Then you need the correct Twitter API address to pull it in on:
https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=twitterapi&count=2or in my case:
https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=moogalooThis just pulls everything into the channel with DataGrab each time the import is run (I used the RSS (Magpie) setting within DataGrab), and map the fields accordingly, setting the author to be the person tweeting.
Next, some template code:{exp:channel:entries channel="tweets_moogaloo|tweets_beamoogaloo" disable="categories|pagination" limit="10" orderby="date" sort="desc" status="open" dynamic="no" search:tweet_text="not moogaloo: @"}
<li class="gr_img {username}">
<img src="{exp:ce_gravatar:single email="{email}"}" width="70" height="70" alt="{author}">
<strong>{exp:tweetify}{exp:low_replace find="moogaloo: " replace=""}{tweet_text}{/exp:low_replace}{/exp:tweetify}</strong>
<cite>
{entry_date format="%d %M '%y"}
| via: {source} |
@{twitter_name}
</cite>
</li>
{/exp:channel:entries}You can either set up a Cron Job for the URL that triggers a DataGrab import (
Notes in setting up Cron Jobs for DataGrab) or set it to pull manually using the template tag.
Then when the tweets start filling up your channel, you can spit em out using the channel:entries tag in a template.
In the above code I've got it pulling the last 10 tweets from 2 twitter feeds (Bea and me), and showing only tweets that don't start with the @.
You'll notice that tweets come in with the username: at the front. Not being a technical API genius, I'm not sure how to stop that, but I've placed the span style="display:none" before the Tweet text, and then used the Low Replace addon to close that span, thereby removing the username: from the visible tweet, but check the code and it's still there.
Killing the conversation, and other such refinementsTo remove the conversational tweets, we're targeting tweets that start with an @. I've kept tweets that include an @ in there as I often use these to mention someone in a tweet but am not directly replying to them, so figure these are OK to keep. For this, I'm using the search:tweet_text="not moogaloo: @" parameter, as can be seen in the
top section of the /twitter/ page I created, “filter: @mentions”.
If you want no tweets with any mentions in you use search:tweet_text="not @"
If you want tweets that have a the #eecms hashtag in, you use search:tweet_text="#eecms",
the 3rd section, “filtered for #eecms”If you've pulled various tweets into one channel and want to show only tweets just by one person, use the author=”” parameter.
If you want to remove a whole stack of content, like Retweets and stuff from your GetGlue auto-tweeting, use a more extensive search parameter, eg search:tweet_text="not moogaloo: @|RT|@getglue",
section 2, “filter: @mentions, RTs & Social Networks”And all that's left is a garnishI used Gravatar to supply the image. Ideally I could pull the actual twitter avatar, but I don't know how to do that.
And Tweetify just makes mentions, links and hashtags become actual links.
I know this isn't exactly the slickest, easiest way of doing this, but it does work where other addon's hit their limitations and offers you a lot of flexibility in terms of which tweets show on your site. I'm also sure there are some more technical minds out there that could refine this process too, get the correct Twitter avatars, remove the username: from the tweet text, in which case, please do comment up and let me know!
Comments [2]