Rather excitingly my little side project tweetyourmp.com was mentioned by pukka chef Jamie Oliver as part of his campaign for healthy eating:
After my panic that I might not have enough bandwidth subsided, I thought it might be a good moment to give Tweety our MP a bit of love, so I’ve added the option to pre-fill tweets.
The tweet text is passed across using a custom URL – this can be done as follows:
Pre-filling in the postcode and tweet message:
Make sure you use the URL http://tweetyourmp.com/index.php
The URL needs to be in the format:
http://tweetyourmp.com/index.php?postcode=SW2 2AX&tweetmsg=twitter message&[email protected]
the parts being:
?postcode= the postcode for constituency lookup
&tweetmsg= the twitter message
&sentvia= the twitter handle for the sender (default is @tweet_your_mp)
You can leave out the postcode (or the tweet message!):
http://tweetyourmp.com/index.php?tweetmsg=twitter message&[email protected]
Passing values to tweetyourmp.com in this way works with spaces, but safer to encode the message and postcode parts using http://andrewu.co.uk/tools/uriencoder/ to replace characters with %20 for a space.
so the above becomes:
This example generates:
hello @ChukaUmunna your twitter message via @kimondo
as the tweet.
Important note on using hashtags
I had to use a bit of a hack to make it possible to have a pre-filled tweet with a hashtag. As # is used to denote an anchor link when you stick it in a URL the rest of the URL gets ignored by the bit of the code that reads the tweet from it.
To get round this use an asterisk * in place of a hash # – the code then puts the hash back in when it sends the tweet:
This hashtag example generates
hello @ChukaUmunna your twitter message #hashtag via @kimondo
The salutation is fixed as ‘Hello’ but can be changed – is important not to begin the tweet with the @handle as it reduces its visibility and ‘Hi’ is a bit American sounding hence the hello.
Next on the list is building some sort of Raspberry Pi based tweet totaliser. You can download the (very simple) code that runs Tweet your MP on GitHub – a couple of interesting options are to use the code in a thankyou email after a supporter has completed an action to give it a bit more impact, or to sort through your data and merge in constituency contacts in an email.
Note that some MPs don’t consider twitter an ‘official’ communication format so this is best combined with an email or letter to an MP.
tweetyourmp.com is made possible thanks to the theyworkforyou.com API – this is free for charitable use up to 50,000 queries.
Update: I’ve now added a page that automates this process and builds a bit.ly link with the correct address!