PHP Classes

PHP Short URL API: Create short URLs and expand them using Google API

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 123 All time: 9,464 This week: 524Up
Version License PHP version Categories
googleurlapi 1.0.0MIT/X Consortium ...5HTTP, PHP 5, Web services


This class can create short URLs and expand them using Google API.

It takes a given URL and sends a HTTP request to the Web server API to request a short version of the URL that is returned by the class as a string.

The class can also send a request the API to expand shorten a URL that was created previously.

Picture of Kevinralph M Tenorio
  Performance   Level  
Name: Kevinralph M Tenorio <contact>
Classes: 5 packages by
Country: Philippines Philippines
Age: 39
All time rank: 337625 in Philippines Philippines
Week rank: 161 Up2 in Philippines Philippines Up
Innovation award
Innovation award
Nominee: 3x



     * @param string $longUrl
     * @param string|null $api
     * @return string|bool
function googl_url($longUrl, $api = null)
$instance = new GoogleURLAPI($api);

        if (
$response = $instance->shorten($longUrl)) {
            return isset(
$response['id']) ? $response['id'] : $longUrl;

$shorten = googl_url('');

// Other Example Usage:

$googlurl = new GoogleURLAPI('MY_GOOGLE_URL_SHORTER_API_KEY');
$short = $googlurl->shorten('');
$long = $googlurl->expand($short['id']);
var_dump([$short, $long]);

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example usage
Plain text file GoogleURLAPI Class Simple Google URL Api Class

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,464
This week:524Up