Malleable Musings

April 25, 2009

Cli.gs and the iPhone – Part 3 (Twitterfon)

Filed under: PHP, cli.gs, iphone, simple hacks — Tags: , , — Brendan @ 10:04 pm

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.

March 25, 2009

Php files and the iphone

Filed under: PHP, iphone, simple hacks — Brendan @ 7:07 am

I’m beginning to think that php files offer an unrivalled way of doing things quickly with the iPhone.

Simply save the file and add the link to the file as a bookmark in Safari.

My most recent effort is a quickly hacked together page which updates my location on Twitter. I simply call the page and my location is updated, a process that otherwise I find quite convoluted (it’s the one missing feature from Twitterfon, although Twitterfon does allow lat/long coordinate updates).

Generally I am in one of three places, at home in Cov, in London at work or in between on the train. So I have four php files (all based on twitter.lib.php file from php classes) bookmarked in Safari, one for each of the three common locations and one for if I am elsewhere (this script has a text input box rather than the location value hard coded).

Blog at WordPress.com.