PHP URL Shortening Class released

I’ve just released PHPShortener, a PHP class that makes it very easy to encode/decode URLs with services such as tr.im, is.gd, and others.

Encoding and decoding is a simple as this:

$s = new PHPShortener();
// encode a long url
$shorturl = $s->encode('http://devthought.com/projects/php/phpshortener/', 'is.gd');
// decode a short url (autodetects the service)
$longurl = $s->decode('http://tr.im/jBBp');

Head to the project page for downloads and documentation. Fork me on GitHub if you want to contribute!

  1. Очень интересно что это такое! Если кто может пояснить, поясните!!! Очень прошу! Я так понимаю это что-то вроде замены URL на необходимый, если не прав то поправте!))

  2. Wouldn’t it be easier to decode using CURL with CURLOPT_FOLLOWLOCATION set to false? This should give you access to “Location: …” headers which should in turn let you find out the target URL without using any APIs and for all possible services.

    • Guillermo Rauch about 1 year ago

      The script can’t assume everyone has cURL. Plus decoding doesn’t use any APIs (can use though).