Thursday, January 17, 2008

iPhone Webclip hack

Well after seing the webclip icons on my iPhone, you want them for all of your favourite bookmarks, what happens if the site hasn't implemented the webclip icon you want?


well heres a simple php script that will force the iPhone to display an icon of your choice


As we know you need a 57x57 icon contained in a link like this




<link rel="apple-touch-icon" href="icon.png">


Well here is some simple php that will allow you to "bounce" the iphone through your own webspace but first setting the clipicon, icon.png that you have on your server




echo '<link rel="apple-touch-icon" href="icon.png">';
header('Location: http://digg.com/news');


Obviously this simple script can be further improved so that you can handle multiple sites via a GET parameter




$site = $_GET['s'];

switch($site)
{

case 'digg':
{
$url ="http://digg.com/";
$icon = "digg.png";
}

default:
{
$url ="http://kieran-hello.blogspot.com/";
$icon = "kieran.png";
}

}

echo '<link rel="apple-touch-icon" href="'.$icon.'">';
header('Location:'.$url);



further improvements would be to alter you .htaccess file so that you can use urls like mysite.com/iphone/digg rather than mysite.com/iphone.php?s=digg