Tag Archives: Social Media

Send pre-filled tweets using tweetyourmp.com

Rather excitingly my little side project tweetyourmp.com was mentioned by pukka chef Jamie Oliver as part of his campaign for healthy eating:

Big yellow sign
Big yellow sign

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:

http://tweetyourmp.com/index.php

?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:

http://tweetyourmp.com/index.php?postcode=SW22AX&tweetmsg=twitter%20message&[email protected]

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:

http://tweetyourmp.com/index.php?postcode=SW22AX&tweetmsg=twitter%20message%20*hashtag&[email protected]

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!

Raspberry Pi powered General Election Swingometer

In the UK it’s election time again and the BBC are preparing to wheel out the latest version of their Swingometer. The BBC Swingometer dates back to 1959, and was a visual device for displaying the balance in seats won by the two main political parties. The Swingometer coined a whole load of phrases along the lines of a ‘swing away’ or ‘swing towards’ a particular party or candidate, and was well suited towards the simple days of two party politics.

Here’s version 1.0 back in 1959:

There's a chap with a pipe behind controlling the arrow
There’s a chap with a pipe behind moving the arrow (photo BBC)

The BBC have more or less stuck to the same device for every election since, although sadly in the same way that CGI ruined the Star Wars films, Swingometers have recently become more and more complicated. This is perhaps also a consequence of the UK moving to multi-party politics where working out who exactly in power after polling day is getting a bit complicated.

Here’s version 14.0 from 2010:

There's just a big green room
There’s just a big green room (photo BBC)

In a tribute to the original, the charity I work for – Concern Worldwide have been using a Development Swingometer, which pays homage to the original 1959 version and tracks the number of candidates who have signed up to support Concern’s 5 pledges on fighting global poverty and protecting international aid (you can tweet them on that page with some code I mashed up using TheyWorkForYou.com and YourNextMP.com).

Building a Raspberry Pi powered Swingometer

As our low-budget version is a bit simple, for a bit of fun I thought I’d build a slightly more technical version that updates itself automatically. My updated Swingometer uses a servo to move the arrow, and a Raspberry Pi to fetch the ‘swing value’ from a web page when you push the big friendly button. The code I’ve used can be edited to fetch more or less any numerical value from a web page and turn it into a ‘swing’ so It should be possible to repurpose this into a political swingometer, or something that displays anything with a value of 1-180 (the angle of swing possible with a servo).

Push the button for results
Just push the button for the latest results

The back of the frame (£5 from Wilko) shows the Raspberry Pi model A and a little slice of Pi board I soldered up. There are two buttons – the big friendly update button for the front and a safe shutdown button on the back, so I can run this without a screen and keyboard.

Here's the back with an arcade machine button and the wiring to the servo
Here’s the back with an arcade machine button (white wires) and the wiring to the servo (brown – red – yellow wires)

The method I’ve used to control the servo is similar to RaspiTV’s Raspberry Pi flag waving post – although I opted for the version detailed in the Raspberry Pi cookbook over Adafruit’s single servo control. For my power supply I used a D-link powered USB hub to supply both the Pi and the Servo via separate USB cables. This results in a slightly wobbly update of the Swingometer arrow, which suits me fine. For more precise control you can use a dedicated servo control hat which can control up to 16 separate servos.

For the code I modified the Raspberry Pi cookbook tutorial code to fetch a value from a web page using Beautiful Soup. You can install this on the pi using:

sudo apt-get install python-beautifulsoup

Note that this installs version 3 – but you’re still able to do lots of clever things to grab content from web pages. If you want to build a political swingometer I’d suggest grabbing values from the election forecast page. There’s a lot more information about using Beautiful Soup on the web page here.

Here’s the code I’ve used to update the swingometer:

import RPi.GPIO as GPIO
import time
from BeautifulSoup import BeautifulSoup
import urllib2

#change this bit
url="http://www.kimondo.co.uk/swingometer-control/"
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())

value = soup.find('span',{'style':'color: #99cc00;'})
value = value.next
value = float(value)

print value

GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 100)
pwm.start(5)
t_end = time.time() + 1

while time.time() < t_end:
        print value
  angle = value/100.0 * 180
  print angle
        duty = float(angle) / 10.0 + 2.5
        pwm.ChangeDutyCycle(duty)

exit()

An alternative I considered was using the Sentiment 140 twitter sentiment tracker API – this tracks positive and negative sentiment towards keyword searches on twitter – although it seems to get fooled by ironic tweets.

If you’ve been inspired to build a Swingometer please share it in the comments! One day I’d quite like to build something like the Weasley clock.

You can ask your election candidates to support Concern’s 5 pledges to fight global poverty and support development here and my fantastic blog about the Development Swingometer on Concern’s website.

We have lift off!

A while ago as part of my Kickstarter habit I excitedly backed a space program. For the princely sum of $10 I get to control a satellite that’s about the size of a coffee machine for 100 seconds.

Sadly Fortunately in this instance the satellite’s functions are limited to sending tweets from space and taking a couple of photos with it’s on-board camera, although the music from Diamonds are Forever will be playing in my head as I imagine wielding control of a thing flying through space – even if it is just for a moment and lacks a laser death ray.

Still it’s rather nice to see a very ambitious Kickstarter funded project come to fruition – given that many more earthly bound campaigns fail after the funding hurdle has been reached.

Here’s the cube blasting off on board supply ship onboard a rocket (launched magnificently from a swamp):

Spaaaaaceship AwaaaaY!
Spaaaaaceship AwaaaaY!

And here it is docking with the International Space Station:

At some point in the future it will be thrown out of an airlock in a graceful launch sequence. Suggestions of things I’m going to make it tweet (along with the 3000 or so other backers) are most welcome – I get 10 historic messages to broadcast from space and the option of 2 photos from the on-board camera.

Tweet your MP

Ever wanted to send a tweet to your MP? not sure if your Member of Parliament has embraced social media? want to put a handy tool to do so on your website?

Tweet Your MP
Tweet your MP

Here’s a little script I wrote to find your MP using a postcode (via the TheyWorkForYou.com API) and send them a tweet. Info, source and background below.

It’s possible to tweak this tool to return email address, postal address, phone number and facebook page (if they have one) – you can also add custom information to each MP as well. My data set includes 436 twitter accounts for MPs – slightly more than Tweetminster’s 409 but I have included auto twitter accounts (so people can see you’re tweeting your MP, even if they don’t respond). I’ve tried to avoid spoof accounts.

Bit of background about this tool

This tool works by converting the postcode into a constituency name on TheyWorkForYou.com, and then matching this constituency name with MP’s details on a local MySQL database table. If you don’t want to use TheyWorkForYou.com’s API it is possible to buy a constituency postcode database from Ordinance Survey for £350.

For a while I’ve been working on an open-source activism tool. It was born out of curiosity, an excuse to learn a bit more about php and as a way of proving email to MP actions courtesy of the very useful theyworkforyou.com API.

Unfortunately it became on of these projects that got more and more complicated – once I’d got round to adding a graphical user front end, SMS texting, and add on modules it started getting a bit too big for me to handle. Plus I started encountering problems with PHP’s send mail function getting blocked by outlook servers, experimented a bit with pop mail senders and then started looking at using online cloud services.

The past 2 organisations I’ve worked for have used off the shelf tools instead, making the aim of the project a little bit redundant.

I still have a copy of all the code (with lots of comments) if anyone would like it – it’s in an alpha sort of works if you’re prepared to spend a bit of time tinkering with it state. Just drop me a line. All I ask is that if you do improve on it, please make it publicly available (it is GPL licensed).

I’ve also been thinking about the effectiveness of email-your-mp actions with identikit emails embedded in them – I think using twitter or even printed out letters might be a better way forward to creatively attract attention, and avoid the boring accusations of ‘slacktivism’.

So in the meantime I’ve taken the bits of the tool that did work, and have reworked them into a much simpler ‘Tweet your MP’ toolkit. The idea of this is to provide a simple widget you can embed on your website – I’ve seen plenty of websites that just link to TheyWorkForYou.com, or refer people to google, so this provides a way of keeping activists on your page.

In the example above I’ve just gone for twitter and website information – but with a few tweaks to the code you can add email your MP (via a mailto link) phone your MP or write a paper letter to your MP functionality.

Requirements & the code

To get this to work you will need access to a MySQL database and PHP. This is currently running on my server which is a cheap-as-chips 123-reg setup. Check your ISP’s documentation for support on how to get these logins. I’ve labelled the code to show what it does.

If there are any corrections please get in touch with me and i’ll add them.

Download the code from GitHub

I’m updating this to fix problems and add enhancements. At the moment the code does contain a bit of stuff left over from the webtivist project. The GitHub version will always be the most up to date.

To make this work you’ll need to upload the MP data spreadsheet to your MySQL server (I used the import function on my 123reg hosting and it worked fine) this has every MP’s contact details – if you’d like access to this please drop me a line as I’d like to keep track of who’s using it!

Then you’ll need to edit the settings.php file to include the login for your MySQL database, the hostname and tablename for your MP database.

You’ll also need to apply for a theyworkforyou.com API key – there’s usually no charge to use this for small volumes. They prefer it if you ask them if you’re intending to use it a lot. Please Please don’t use this to send identical emails to MPs.

For the twitter part you’ll also need a Twitter API key  I changed this to use the more simple @mention option on twitter.

Corrections / suggestions and contributions

Thanks to MPs being arrested for things, standing down or departing, this data may become out of date over time.  If there is incorrect information please let me know and I’ll update it.

This script makes use of the TheyWorkForYou.com API and Ruben Arakelyan’s php script. Check the comments in the code for more information.

Update: this script has now moved to tweetyourMP.com

Twitter’s not just for elections…

I’m often looking for ways to engage with my MP – usually online, since that’s how a lot of things are done in the 21st century (banking, paying bills, booking travel etc). However sometimes I get a little bit despondent about writing to elected representatives who then don’t respond.

Neither my last MP Vince Cable, or now (since I’ve moved to Kingston) Ed Davey seem to do the online thing, with not much response to email and no tweets since May 2010.

In fairness, both seem to blog quite a bit and I haven’t yet tested their response rate to a dead-tree format letter.

But this got me thinking – is twitter and social media truly a way for MPs to reach out and engage with their electorate? or is it just a handy tool for some publicity every 4 years when they want our votes.

It would be a shame if the latter were true, since it’s a relatively easy way to publish information, particularly to a younger audience.

So I’ve compiled a list of MPs who haven’t tweeted in the last 6 months (most haven’t since the last election), along with a count of their followers:

Twitter MP followers
@vincecable
22094
@Vaizeyculture
3863
@Mike_Fabricant
2639
@HazelBlearsMP
2522
@DavidWrightMP
2507
@VirendraSharma
2505
@AlanDuncan4MP
2494
@leighmp * – now moved to @andyburnhammp and updated!
2004
@markdurkan
1946
@KarenBuckMP
1780
@naomi_long
1766
@eddaveykands
1543
@gildernewmp
1518
@Linda_Riordan
1489
@acarmichaelmp
1462
@Moore4Borders
1443
@nicolablackwood
1328
@kwasikwarteng
1026
@JDjanogly
885
@DavidEDrew
823
@Michael_Ellis1
658
@rosie4westlancs
634
@AMcDonnellMP
616
@George4MVMP
562
@NickSmith4BG
516
@PhilipDavies422
507
@C4NWestminster
452
@MaryMacleod4MP
449
@StocktonNorth
378
@edwardleighac
76

With over 22 thousand followers Vince Cable is missing a trick. Perhaps he’s lost the password?

As always corrections and feedback most welcome.

Update – @leighMP is now @andyburnhammp which is regularly updated – thanks to @CollectorManiac for pointing that one out.

Updated update: check out more MP twitter information at tweetyourMP.com

Trying out Google plus one (updated)

I’ve just had a go at installing the new Google like plus one button on this blog. It’s available in US English only and you have to opt in to the experiment in order to get it to work properly.

There are some handy instructions available on google on adding the button – it involves some Javascript in the header and a plus one tag <g:plusone></g:plusone> to render the button.

 

Not entirely sure how useful this is – particularly if it’s just related to Google Buzz which picks up my twitter feed anyway.

It seems very similar to Facebook like, but lacking the massively popular social network to back it up.

Update:

Now the plus one button has a massively popular social network (10 million users by July 2011) to back it up – the launch of Google Plus integrates with the button. For anyone not yet on plus one, in 10 seconds it:

  • Has an activity stream just like facebook.
  • Allows you to organise contacts using a neat drag and drop interface into ‘circles’ e.g. friends, family, colleagues which is much easier to use than facebook’s privacy settings.
  • Allows you to share content with each circle differently e.g. hello friends here are my drunken photos from last night, hello colleagues here is my presentation for today’s meeting, again facebook sort of allows this but it’s horribly complicated to set up.
  • Has a group video conference feature.
  • lacks group or organisation/company pages – although this feature is coming soon.

The sharing content bit is where the plus one button comes in. Initial testing indicates that it helps with discovery of new pages into google, but has no effect on their page ranking.

Don’t retweet this to get the #newtwitter

Well it seems the new twitter is finally hitting the UK with the #newtwitter hashtag topping the trending charts, although it seems that many are falling for the “follow me / retweet me” to get access to new twitter, which sadly doesn’t work. Anyone who claims to be able to unlock the new twitter for you is a big fat liar.

Image of the new twitter page
All change here

The new layout features a 50/50 split between the twitter stream and trending, lists and suggestion columns – which should suit the more popular widescreen monitor formats. Search is more prominently sitting at the top of the page, and lists and searches are included in dropdown menus. Clicking on a tweet operates a slide out page with more information on that tweet or user.

The new layout seems to have messed up a lot of custom backgrounds although these are a bit of an ugly hack which attempt to shoehorn more contact information onto a twitter page.

In terms of new features – twitter have now launched shortcuts to a lot of the common twitter functions:

Image of twitter short cuts
Just like a twitter client

Hitting a key brings up a lightbox style popup window with the appropriate function.

Favourite tweets also have a bit more prominence as well, which is a feature I’ve hardly bothered with.

The overall feel is that twitter.com includes more of the features of the many twitter clients that are available – which in itself is perhaps a reaction to the laissez-faire attitude twitter has to it’s service: build too good an API and no-one will visit your website anymore.

Trying out the *new* digg

Digg isn’t the website it once was, and I must admit I generally turn to twitter now for the latest news from the rumour mills before it hits the official news sites. Despite it’s drop in traffic and influence Digg still commands a large (although male-student-dominated) audience. There’s now a ‘new digg’ with a simpler interface which harks back to the original feel of the site.

Digg screenshot
All change here

One of the interesting features is the ability to import feeds directly – so perhaps digg will become what it intended to be – a democratic way of voting for news that’s interesting. Or it might just remain “top 10 hot pictures of Christina Hendricks / 10 Star Wars characters you’d forgotten about/ top 100 1990’s video games”.

There’s a lovely infographic with a potted history of Digg available from Online Schools.

If you’d like an invite to New Digg I have a few spare – give me a shout on twitter @kimondo

My validation code is below, it activates this blog feed in Digg (although I’m not expecting the Digg effect any time soon)

<!–1f7e876ed8f9445d9c92e3a69c06179a–>

A week of social media fails…

Social media:  a potentially exciting new way for businesses and organisations to have conversations with their stakeholders; a way of developing a campaign or a brand with a personal touch, or potentially a way to really stick their foot in it and magnify criticism to epic levels.

Killer KitKats

This week saw two interesting social media ‘fails’. First we had Nestlé’s reaction to a greenpeace video about their use of palm oil in KitKat.  The increasing use of Palm oil has resulted in devastating destruction of rainforests and peatlands to create vast monoculture plantations. It’s a classic ecowarriors versus evil-corporation style campaign which is gaining a lot of support. Greenpeace’s opening shot is here:

I must admit, it’s a quite horrible shock advert in the usual Greenpeace style – Nestlé’s response was to get the video taken down from YouTube citing infringement of their trademarked logo.  Almost since the beginning of YouTube what usually happens when a video is taken offline,  a copy will be almost immediately uploaded again;  and Greenpeace of course used this response to generate support for their campaign, and even made the original available for supporters to upload using their own accounts.

The effect was immediate with tweets and facebook updates being bound around mentioning Nestlé’s censorship tactics – a suitably rebellious message which is popular for users of social media to repeat and pass on.

This is a classic example of the ‘Streisand effect ‘ in which an attempt to censor or remove a piece of information from the public domain has the unintended consequence of generating more publicity than if it had just been left online.

Nestlé didn’t stop there however: inevitably as their Facebook page became the source of comments and questions about their use of Palm oil, Nestlé instead responded angrily to the use of their logo as an avatar image, again resulting in yet another deluge of tweets and status updates.

The end result was Greenpeace claiming the upper hand, and Nestlé looking out of step with the campaigners and their customers.

#CashGordon – whose fail?

The other social media ‘fail’ of the past week has been the Conservative website launched to promote the message that Gordon Brown is supported by money for the Unite Union – currently supporting a strike by British Airways workers that has divided opinion. Interestingly the CashGordon  site features an unmoderated twitter stream repeating every tweet with the #cashgordon hashtag. It’s a particularly old school concept which dates from when twitter was a relatively new phenomenon, and having anyone tweet about your site was quite exciting.

The more left wing tweeters have jumped on this hashtag with a stream of abuse – many of which are too rude to put here, but which include things like:

@fusi_loving the EPIC FAIL that is #cashgordon – they cant even get a twitter feed right, what are they gonna do with the economy? lol. #toryfail

and

@lordbonkers Write something rude about the Tories, mark it#cashgordon and they post it on their own campaign site for youhttp://cash-gordon.com/

and the rather damming:

@psbook New post –> Tory ‘Cash Gordon’ campaign designed by US anti-healthcare lobbyist http://is.gd/aSFIF #cashgordon

Interestingly however the very presence of the website, and the numerous comments on the #cashgordon hashtag has had the unintended consequence of bringing the whole campaign to the attention of a much wider audience (at time of writing #cashgordon is trending in the top ten of the UK) which itself is being claimed as a success.

Update: I’ll see if I can tally up the tweets to see who can claim victory on this one

Another Update: nope, quite clear epic fail

Anatomy of a hashtag #cashgordon
Epic fail