Dec 12

Where did my Twitter feed go?

As of March 2013, Twitter say that “we will require every request to the API to be authenticated“. In practical terms, this means your old widget on your blog will most likely break. What to do? Well, there will certainly be some new WordPress widgets coming soon. If you’re building something now and don’t want to wait, it’s slightly more difficult but only slightly.

I’m now using the plugin “oAuth Twitter Feed for Developers” and an edited version of the example code to layout tweets by Emma from Red Earth Design. The example code meets Twitters new design guidelines, too, bonus! I’ve tweaked both a little – this post will tell you how and why. I’m not going to go into how to use the plugin, it has easy to follow directions.

First, the changes I wanted to make:

  • Retweets were being truncated eg:
  • Replies were being included. Mine are usually stupid. I wanted them out.
  • I wanted to use it as a shortcode in which the number of tweets was passed as a parameter
  • After I had sorted all of the above, the tweets were showing up at the top of the page instead of where they were supposed to be. This needed to be fixed.

Instead of going through the changes one by one, I’ll tell you which files I edited and why.

File 1: oauth-twitter-feed-for-developers/StormTwitter.class.php in the oAuth Twitter Feed for Developers plugin files

Towards the end of this file is this line:

$result = $connection->get('statuses/user_timeline', array('screen_name' => $screenname, 'count' => 20, 'trim_user' => true));

I’ve edited it to this:

$result = $connection->get('statuses/user_timeline', array('screen_name' => $screenname, 'count' => 100, 'trim_user' => false, 'exclude_replies' => true));

Here’s what I added / changed:

‘exclude_replies’ => true;  this should be pretty obvious. I wanted to exclude replies.

‘trim_user’ => false;  I had to change this to get the screen name (eg mine is tharsheblows) for authors of retweeted statuses

‘count’ => 100; when I had twenty, I only ended up with fourteen non-reply tweets – I guess the count is applied first, then the replies are excluded? Not sure, can’t be bothered to trawl to find out a definitive answer.

Also, for testing purposes, I changed the cache time below (currently set at one hour) which is in this file. The main thing is to remember to change it back before putting it anywhere you could hit your rate limit:

if ($cache['time'] < (time() - 3600)) 

File 2: Example code to layout tweets

edit 31 December 2012: the code below throws out some empty <a></a>’s. I don’t know why and it still works (but looks ugly and doesn’t validate if you’re into that) so it’s going to the bottom of the list to be fixed. I will update again if I do.

Using the code linked to above, the retweets were causing some problems – once I had the whole tweet, the display went a little wonky. Their information is in the retweeted_status object and needed to be found there. For some reason, I couldn’t find the original tweeter’s screen name, so had to access it like a regular tweet. Anyway.

I also added some extra divs to make it eaiser to style. You’ll end up with something like this:

<div class=”twitter_box”>
<div class=”tweet”>THE TWEET</div>
<div class=”twitter_intents”><p>LINKS TO REPLY, RETWEET AND FAVORITE</p></div>
<p class=”timestamp”>TIMESTAMP LINKED TO STATUS</p>

Looking at that, I’m not sure I like that layout. I might change it. It really should be a list, shouldn’t it.

The tweets showing up at the top of the page thing was due to the function echo-ing the output as it went along instead of returning it. I changed this.

Here is the final code (it goes in functions.php as usual) – oh, and if you use this, you will want to change “tharsheblows” to whatever your Twitter screen name is. I can’t be bothered to make this non-hard coded:

// dealing with Twitter - adapted from https://github.com/stormuk/storm-twitter-for-wordpress/wiki/Example-code-to-layout-tweets
// http://wordpress.org/extend/plugins/oauth-twitter-feed-for-developers/

function twitter_display($tweet, $status, $the_tweet){
Twitter Developer Display Requirements

2.b. Tweet Entities within the Tweet text must be properly linked to their appropriate home on Twitter. For example:
i. User_mentions must link to the mentioned user's profile.
ii. Hashtags must link to a twitter.com search with the hashtag as the query.
iii. Links in Tweet text must be displayed using the display_url
field in the URL entities API response, and link to the original t.co url field.

// i. User_mentions must link to the mentioned user's profile.
foreach($status['entities']['user_mentions'] as $key =&gt; $user_mention){
$the_tweet = preg_replace(
'&lt;a href="http://www.twitter.com/'.$user_mention['screen_name'].'" target="_blank"&gt;@'.$user_mention['screen_name'].'&lt;/a&gt;',

// ii. Hashtags must link to a twitter.com search with the hashtag as the query.
foreach($status['entities']['hashtags'] as $key =&gt; $hashtag){
$the_tweet = preg_replace(
'&lt;a href="https://twitter.com/search?q=%23'.$hashtag['text'].'&amp;src=hash" target="_blank"&gt;#'.$hashtag['text'].'&lt;/a&gt;',

// iii. Links in Tweet text must be displayed using the display_url
//      field in the URL entities API response, and link to the original t.co url field.
foreach($status['entities']['urls'] as $key =&gt; $link){
$the_tweet = preg_replace(
'&lt;a href="'.$link['url'].'" target="_blank"&gt;'.$link['url'].'&lt;/a&gt;',
return $the_tweet;
}//end twitter_display

//twitter shortcode function
function twitter_shortcode($atts){

extract( shortcode_atts( array(
'number' =&gt; '5',
), $atts ) );

$tweets = getTweets($number);

// to use with intents
echo '&lt;script type="text/javascript" src="//platform.twitter.com/widgets.js"&gt;&lt;/script&gt;';
$tweet_box = '&lt;div&gt;';
foreach($tweets as $tweet){


if (isset($tweet['retweeted_status'])){
$the_tweet = "RT  @".$tweet['retweeted_status']['user']['screen_name'].": ".$tweet['retweeted_status']['text'];
//I had to add in this next foreach to get the tweeter's link correct - not sure why
foreach($tweet['entities']['user_mentions'] as $key =&gt; $user_mention){
$the_tweet = preg_replace(
'&lt;a href="http://www.twitter.com/'.$user_mention['screen_name'].'" target="_blank"&gt;@'.$user_mention['screen_name'].'&lt;/a&gt;',
$the_tweet = twitter_display($tweet, $tweet['retweeted_status'], $the_tweet);

$the_tweet = $tweet['text'];
$the_tweet = twitter_display($tweet, $tweet, $the_tweet);


$tweet_box .= '&lt;div&gt;'.$the_tweet.'&lt;/div&gt;';

// 3. Tweet Actions
//    Reply, Retweet, and Favorite action icons must always be visible for the user to interact with the Tweet. These actions must be implemented using Web Intents or with the authenticated Twitter API.
//    No other social or 3rd party actions similar to Follow, Reply, Retweet and Favorite may be attached to a Tweet.
// get the sprite or images from twitter's developers resource and update your stylesheet
$tweet_box .= '
&lt;p&gt;&lt;a href="https://twitter.com/intent/tweet?in_reply_to='.$tweet['id_str'].'"&gt;Reply&lt;/a&gt; |
&lt;a href="https://twitter.com/intent/retweet?tweet_id='.$tweet['id_str'].'"&gt;Retweet&lt;/a&gt; |
&lt;a href="https://twitter.com/intent/favorite?tweet_id='.$tweet['id_str'].'"&gt;Favorite&lt;/a&gt;&lt;/p&gt;

// 4. Tweet Timestamp
//    The Tweet timestamp must always be visible and include the time and date. e.g., “3:00 PM - 31 May 12”.
// 5. Tweet Permalink
//    The Tweet timestamp must always be linked to the Tweet permalink.
$tweet_box .= '
&lt;a href="https://twitter.com/tharsheblows/status/'.$tweet['id_str'].'" target="_blank"&gt;posted at
'.date('g:i A \o\n d M Y',strtotime($tweet['created_at'])).'
} else {
$tweet_box .= '
&lt;br /&gt;&lt;br /&gt;
&lt;a href="http://twitter.com/tharsheblows" target="_blank"&gt;Click here to for more tweets from tharsheblows&lt;/a&gt;';
}//foreach $tweets as $tweet
}//if is_array($tweets)

$tweet_box .= '&lt;p&gt;I\'m &lt;a href="http://twitter.com/tharsheblows" target="_blank"&gt;tharsheblows&lt;/a&gt; on Twitter.&lt;/p&gt;';

$tweet_box .= "&lt;/div&gt;&lt;!-- tweet_box --&gt;";

return $tweet_box;

}//end twitter_shortcode function

add_shortcode('tweets', 'twitter_shortcode');
//end twitter stuff


I’m using a minimum of css right now:

/*oauth twitter stuff */
.twitter_box{padding: 10px 0 0 0; border-bottom: 1px #E2E2E2 solid;}
.twitter_intents p{text-align: right; font-size: 80%; margin-bottom: 0; padding-bottom: 0;}
p.timestamp {font-size:80%; text-align: right; padding: 0; margin-bottom: 3px; }

And that’s it!



Dec 12

Bath oils – a practical exercise to follow the previous bath oils post

You need to read the post on how to purchase bath oils as gifts first. Go on now, this won’t make much sense otherwise. Ok. Do you have a general idea of how to handle it? Let’s give it a whirl in a practical setting.

Today I received an email from Space NK, Delectable Bathing Gifts + FREE DELIVERY. Annoying shouting in the subject line aside, it’s a list of sets of bathing products to buy as gifts. Have a look. We’ll go through them one by one. I’m not going to deconstruct the email but will instead, for clarity, focus on the sets and take each one separately. I make no pretense of adhering to the principals I advocated previously.

British Bathing Heroes – Beautannia

Why they didn’t make this a proper alliteration, I’ll never know. Some people. Anyway. Product photo:


Best of British bathing by Beautannia. That’s not the real name. The real name is British Bathing Heroes by Beautannia. Doesn’t mine sound better?  The image is from Space NK.

So what do we know about this? It’s four bottles of Space NK’s own brand (new own brand) shower gel. Each is 100mL (I think – it doesn’t say on the site but mentions in the email – anyway, 100mL is about 1/2 a bottle, I’ll keep repeating this). It’s £30. Now, yesterday or the other day or whenever, I wrote that you shouldn’t buy Space NK own brands unless you’re sure your gift recipient likes them. Thinking about it and the fact that I am quite keen to try these in particular, in this form, four at once without a massive commitment, I am going to slightly change that advice. If your recipient starts to stress a bit when she has only 3 different gels sitting in the shower and likes Space NK, then this might be a good gift. HOWEVER, I think there is an above average chance they will be in the sale. So maybe not, especially if she avidly shops the sale. Clouding my opinion is the bumpf:


Try using invigorating Balfour and Brighton to get you started in the morning, and the more calming fragrance of Bloomsbury or Brideshead just before you go to bed.

I love that sort of thing. Never believe the medical benefits, go with the stuff where the placebo effect can kick serious ass.

Rose Experience Gift Set by REN


Rose Experience Gift Set by REN at Space NK.

It’s REN, it’s rose, it’s lovely. 100mL (1/2 bottle ish) of the body cream and body wash and 30mL of the body oil and bath oil. It’s £32 and even though the body cream makes the body oil slightly redundant, it’d still make a lovely gift, I think. There’s also a smaller set for £18 which doesn’t have the body oil and has smaller versions of the cream and wash but still has 30 mL of the bath oil.

Ultimate Collection by Aromatherapy Associates

Ultimate Collection by Aromatherapy Associates as Space NK

We’ve been over this already. It’s a winner. What do you mean you don’t know that we’ve been over this already? Didn’t you read the previous post about bath oils? It’s in there. Space NK also has a version of this with a bit less in each mini bottle for a bit less money, but this one has 7.5mL samples, enough for one greedy bath or two not-so-greedy baths per bottle. That one has 3mL per bottle, enough for one bath. This one is £50, that one is £30.

Drift Away Collection – Life NK

Do I have to put a photo with this? Sigh. Here it is.

Drift Away Collection by life NK

I haven’t smelled this but am worried about the smell. Don’t buy this one, again, chances are it’ll be in the sale. If you want to buy something to sample the Life NK scents, try the Bath and Shower Gel Trio instead. This is £20. Not sure about sizes.

Essential Mineral Set by Sai-Sei

Essential Mineral by Sai-Sei at Space NK

I want to try this brand. But not like this. Soap? Who wants hard soap with a loofah in it? I mean, I can see wanting it but this is what it says…

How to apply:

Use Mineral Refresh Bath and Shower Gel and the Mineral Loofah Body Polish Soap to gently cleanse, exfoliate and tone. After bathing, apply Mineral Deep Moisture Body Cream to nourish and soften skin.

What? I totally don’t get it. Use the shower gel with the soap? No. That’s just weird. (Now I want to try it, of course.) However, here’s a good alternative if you like the look of it and, say, know your wife wants it: Essential Minerals (a similar name, I will admit, and a similar set except with a little fancy shower puff which makes way more sense). The shower gel and moisture cream are full size or close to itaccording to the email and I think it’s cheaper at £50 than buying them all separately.

Tarte Au Citron Bath & Body Duo by Laura Mercier

Something with lemon custard? by Laura Mercier at Space NK.

My husband once turned to me and said “You smell like a cupcake”. It wasn’t a compliment and I agreed, I smelled like a cupcake. I was trying to use up some sample body cream but gave up and threw it out. What I’m trying to say is that I’m unsure about smelling like a dessert. You can ooh and errr all you’d like about emitting an edible scent, but when it comes down to it, it’s not for everyone. Not for me at least. It does look nice and I’m sure it is nice, you get 150mL of each plus a dippy thingy for £25.

Last but not bathing related, the bottom of the email had Cellularose Brightening Cream by By Terry. I don’t think cellularose is a word but I want it.

And if you’re using this to buy presents, it’s at your own risk. How do I know?



Dec 12

Music for parents with small children

First up,  Stay Awake: Various Interpretations of Music from Vintage Disney Films. It’s a bit bonkers. The track list is available on Wikipedia.

Tom Waits sings Heigh Ho, The Dwarves’ Marching Song


My favourite is Suzanne Vega’s Stay Awake.


Second (last, it’s a short list) cd: Kristin Hersh’s Murder, Misery and Then Goodnight. These are lullabies. Lullabies in which a woman is drowned and the baby gets a bottle of gin amongst other things. My dad remembers these from when he was little, growing up in Tennessee.

Kristin Hersh: What’ll we do with the baby-o?




Dec 12

Some bath oils : Buy, buy again (again but these are for other people to buy you)

I have strong opinions on bath oils; it’s strange because I’m not hugely picky. Nevertheless, let me tell you how to buy bath oils for women.

Currently waiting to be used.

1. Buy a single bottle or small set of the good stuff (more on the good stuff below).

Don’t buy a gigantic set of products, eg this Soap and Glory set with everything you could need, plus mascara. Chances are, she won’t use half the stuff and each individual item is not terribly expensive on its own. She can buy it herself. Unless she’s asked for this! Then by all means, buy it for her. Why are you even reading this?

2. Buy your bath oil from a boutique or Space NK.

I think it’s less fun to get something you see when you’re out grocery shopping – makes it a bit everyday, don’t you think? Ordering online is ok, but there is no reason to use Amazon. Wean yourself from it. They are pretty evil. You are clever, you can find somewhere else and this post has links. Don’t sell out for a pound or two (or five or ten even).

 3. Don’t buy Space NK own brand.

Space NK’s own brand is hit or miss. Sometimes the misses are wildly off. I haven’t tried their new Beautannia range (hidden own brand) but just pick something else unless you’re sure she’ll like it.

Now for the fun part: here’s what I have and love. I have received all of these repeatedly as presents and am happy each time I do.

Aromatherapy Associates bath oils. Each is enough for a single bath.

If the woman for whom you are buying likes buying teas to revive & revitalise, to cleanse or for a moment of calm,  then she will probably like Aromatherapy Associates. They have bath oils to Relax, De-stress and Revive, to Support Equilibrium– the bumpf says

For when the going gets tough and you’ve got to keep going , therapeutic levels of pure essential oils combine to create a bath and shower oil that will help restore balance and positive thinking. Highly effective during times of stress and emotional upheaval, Support Equilibrium Bath & Shower Oil can also be enjoyed as part of a pampering bathtime soak.

– and much more. Buy the Ultimate Collection this year and next time, buy her the ones she likes best.

REN Moroccan Rose Otto Bath Oil

If she likes rose, then, easy, buy REN Moroccan Rose Otto Rose Bath Oil. It’s absolutely lovely. There’s not much more to say, this is the best rose bath oil out there.

Ortigia Lime Di Sicilia

Ortigia Lime Di Sicilia Bath Oil smells like I imagine Italy. I do mean imagine, not remember – I don’t remember anywhere in Italy smelling like this, although there were some excellent smells. This is limes and summer and soothing skies.

Another excellent brand I love – but have recycled the bottles – is Abahna. They have discontinued my favourite, the Frankincense and Sweet Orange, bastards.