PHP class for expanding and shortening URLs using Google URL shortener API







I have combined the 2 previous posts for expanding and shortening goo.gl URLs and have created a small class for it. Below is the download link for the class.


Download GAPIClass


Expanding a URL
expand('http://goo.gl/WlFX');
if(FALSE === $result)
{
echo $objAPI->error;
}
else
{
echo 'Long URL:'.$result;
}
?>
Shorten A URL
shorten('https://www.packtpub.com/php-jquery-c...

if(FALSE === $result)
{
echo $objAPI->error;
}
else
{
echo 'Short URL:'.$result;
}
?>

As I have mentioned e...

 •  0 comments  •  flag
Share on Twitter
Published on January 20, 2011 11:55
No comments have been added yet.