2017 © Pedro Peláez
 

library url-shortener

This library helps you to generate shortlinks for long url using different URL Shorteners.

image

twodevs/url-shortener

This library helps you to generate shortlinks for long url using different URL Shorteners.

  • Saturday, April 18, 2015
  • by Zeichen32
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

UrlShortener Library

Latest Stable Version License Build Status, (*1)

This library helps you to generate shortlinks for long url using different URL Shorteners., (*2)

Supportet URL Shortener

Installation

The preferred way to install this library is to use Composer., (*3)

    $ composer require twodevs/url-shortener ~1.0

Choose a http client support by Ivory HttpAdapter, (*4)

    $ composer require guzzlehttp/guzzle ~5.0

General Usage

    // Create a client
    $client = new \GuzzleHttp\Client(['defaults' => ['verify' => false]]);

    // Create the Adapter
    $adapter = new \Ivory\HttpAdapter\GuzzleHttpHttpAdapter($client);

    // Create BitlyShortener
    $shorter = new \TwoDevs\UrlShortener\Provider\BitlyProvider($adapter, ['access_token' => 'your-token']));

    // Shorten a long url
    $shortUrl = $shorter->shorten('http://example.org');

    // Expand a short url
    $longUrl = $shorter->expand($shortUrl);

    var_dump( (string) $shortUrl );
    var_dump( (string) $longUrl );

Using chain provider

    // Create a client
    $client = new \GuzzleHttp\Client(['defaults' => ['verify' => false]]);

    // Create the Adapter
    $adapter = new \Ivory\HttpAdapter\GuzzleHttpHttpAdapter($client);

    // Create ChainProvider and attach bitly, google shortener and Tiny-Url
    $shorter  = new \TwoDevs\UrlShortener\Provider\ChainProvider();
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\BitlyProvider($adapter, ['access_token' => 'your-token']));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\GoogleProvider($adapter, ['key' => 'your-key']));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\OwlyProvider($adapter, ['key' => 'your-key']));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\TinyUrlProvider($adapter));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\IsgdProvider($adapter));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\VgdUrlProvider($adapter));

    // Shorten a long url
    $shortUrl = $shorter->shorten('http://example.org');

    // Expand a short url
    $longUrl = $shorter->expand($shortUrl);

    var_dump( (string) $shortUrl );
    var_dump( (string) $longUrl );

License

The TwoDevs UrlShortener is under the MIT license. For the full copyright and license information, please read the LICENSE file that was distributed with this source code., (*5)

The Versions

18/04 2015

dev-master

9999999-dev

This library helps you to generate shortlinks for long url using different URL Shorteners.

  Sources   Download

MIT

The Requires

 

The Development Requires

bitly url shortener ow.ly google url shortener tineurl is.gd v.gd

18/04 2015

1.0.2

1.0.2.0

This library helps you to generate shortlinks for long url using different URL Shorteners.

  Sources   Download

MIT

The Requires

 

The Development Requires

bitly url shortener ow.ly google url shortener tineurl is.gd v.gd

18/04 2015

1.0.1

1.0.1.0

This library helps you to generate shortlinks for long url using different URL Shorteners.

  Sources   Download

MIT

The Requires

 

The Development Requires

bitly url shortener ow.ly google url shortener tineurl

16/04 2015

1.0.0

1.0.0.0

This library helps you to generate shortlinks for long url using different URL Shorteners.

  Sources   Download

MIT

The Requires

 

The Development Requires

bitly url shortener google url shortener tineurl