The URL shortening service TinyURL.com provides an API for programmatically processing URL shortening requests through your own script.
It’s actually pretty easy.
function short($url) { return file_get_contents("http://tinyurl.com/api-create.php?url=".$url); }
Alternatively, you can use cURL to download remote URLs contents if your server doesn’t support file_get_contents.