Twitterfon is definitely my favourite Twitter client for the iPhone. Although I still haven’t tried Tweetie but according to this post there really isn’t much in it. So I was excited earlier this evening to discover the bookmarklet on the Naan Studio website (hadn’t realised that they also produced the excellent Twitterfox add-in for Firefox as well).
On using the bookmark I noticed whilst it posts shortish URL’s in full for long URL’s it uses the tinyurl.com shortener. I’ve nothing against tinyurl, in fact many years ago I used to use them extensively when sending bulk email however today there are much better URL shortners to choose from. So I hacked together a little PHP script to create private cli.gs (N.B. you’ll need to add your cli.gs API key in the place indicated).
<?php
$url = $_GET['url'];
$title = $_GET['title'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, "http://cli.gs/api/v1/cligs/create?
key=[API key goes here]&appid=BFphpscript&url=".urlencode($url)."&title=".urlencode($title));
$output = curl_exec($ch);
curl_close($ch);
header("location: twitterfon:///post?".$output);
?>
You’d then need to call it in the usual way – i.e. via a bookmark of
javascript:(function(){%20window.open('[location of php script]?url='
+encodeURIComponent(location.href)%20+'&title='+encodeURIComponent(document.title));%20})();
I’m hoping that eventually I’ll figure out a better final line of the php script, i.e. something that can transfer more than just the URL over to Twitter, unfortunately there’s very little documentation for Twitterfon, the only thing I found other than on the Naan website was this piece from someone who had a similar idea of using a php script a couple of weeks ago.
