UrlShortnerApi
URL Shortner API shortens the url with Google short service and also TinyUrl shortening service., (*1)
It takes the long url and converts it into the short url., (*2)
Uses Strategy Design Pattern, (*3)
It also takes the short url and sends the statistics and also the long url., (*4)
Begin by installing this package through Composer. Edit your project's composer.json file to require`., (*5)
"require": {
"leela/urlshortnerapi": "1.1"
}
Next, update Composer from the Terminal:, (*6)
composer update
That's it! You're all set to go., (*7)
Usage for tiny url Shorten
<?php
$tinyUrlInstance = new \Leela\services\TinyUrlShortner(TINYURL_API_KEY);
$urlshortner = new Leela\UrlShortner($tinyUrlInstance);
try {
echo $urlshortner->getLongUrl($shortUrl, $total_options);
echo $urlshortner->getShortUrl($longUrl);
} catch (Exception $e) {
echo $e->getMessage();
}
Usage for Google url Shorten
<?php
$googleUrlInstance = new \Leela\services\GoogleUrlShortner(Google_API_KEY);
$urlshortner = new Leela\UrlShortner($googleUrlInstance);
try {
echo $urlshortner->getLongUrl($shortUrl, $total_options);
echo $urlshortner->getShortUrl($longUrl);
} catch (Exception $e) {
echo $e->getMessage();
}
Methods
getLongUrl($shortUrl, $total_options);
$shortUrl = Google Shorten Url or tiny shorten url
$total_options = TRUE or FALSE;
TRUE returns all the history list of the url
FALSE returns only the public url;
getShortUrl($longUrl)
$longUrl - The actual url need to be shorten;
Contributor
Leela Narasimha Reddy - leela@leelag.com, (*8)
Issues & Suggestions
Please report any bugs or feature requests here: https://github.com/leelanarasimha/UrlShortnerApi/issues, (*9)