Official library

Create safe short links from your PHP web site or application. The current version is 1.1.0.

SafeMn-1-1-0.php.zip for shortening, expanding and tracking URLs in PHP.

Code

<?php
 require_once('lib/safemn.class.php');
 $safe = new Safemn();
 $url = $safe->shortenSingle('http://www.reviews-web-hosting.com/');
 $urlexpanded = $safe->expandSingle($url);
 $info = $safe->infoSingle($url);
 echo 'Short: ' . $url;
 echo "\n";
 echo 'Long: ' . $urlexpanded;
 echo "\n";
 echo "Clicks: " . $info->clicks;
 echo "\n";
?>

Output

Short: http://safe.mn/d
Long: http://www.reviews-web-hosting.com/
Clicks: 185

3rd-party library

An other library by Stanislav Shramko, LGPL (expand/shorten only).