Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A unified PEAR interface for creating and expanding short URL's.
PHP
Branch: master
Pull request Compare This branch is 3 commits ahead, 10 commits behind joestump:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Services
tests
README.textile
package.xml

README.textile

Services_ShortURL

Introduction

Services_ShortURL is an abstract interface to the plethora of short/tiny/miny
URL services written in PHP5 for PEAR. It allows you to easily create or expand
short URL’s. In addition to expanding and shortening short URL’s it has helper
functions for detecting what type of short URL service a URL belongs to and
extracting short URL’s and expanding them from blogs of text.

Services

  • bit.ly
  • Digg
  • is.gd
  • short.ie
  • TinyURL
  • tr.im

Shortening a URL


<?php

$url = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html';
require_once 'Services/ShortURL.php';

$api   = Services_ShortURL::factory('TinyURL');
$short = $api->shorten($url);

// I'm short!
var_dump($short);

?>

Expanding a URL


<?php

$url = 'http://tinyurl.com/jumvn';
require_once 'Services/ShortURL.php';

$api  = Services_ShortURL::factory('TinyURL');
$long = $api->expand($url);

// Should be http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html
var_dump($short);

?>

Something went wrong with that request. Please try again.