tzsk/shorten-url

This package is abandoned and no longer maintained. No replacement package was suggested.

Google URL Shortener and Expander for Laravel.

2.0.0 2019-09-30 18:17 UTC

This package is auto-updated.

Last update: 2020-09-30 01:47:15 UTC


README

Latest Version on Packagist Software License Scrutinizer Code Quality Quality Score Total Downloads

Package for Shortening URL and Expanding URL with Google. This is a great combination if you plan to send Links in your Text Messages fired from your Application.

Install

Via Composer

$ composer require tzsk/shorten-url

Configure

First add the Service Provider and Facade in your app config file.

'providers' => [
    ...
    Tzsk\ShortenUrl\Provider\ShortenUrlServiceProvider::class,
    ...
]
...
'aliases' => [
    ...
    'GoogleUrl' => Tzsk\ShortenUrl\Facade\GoogleUrl::class,
    ...
]

After that run vendor:publish with flag config:

$ php artisan vendor:publish --tag=config

Once you do that you will have a new file in your config folder. config/url.php

There is only one criteria. Google API key for Shortening URL. Just login with google account and go to [https://console.developers.google.com]

Now create a new Application there. And Enable API for URL Shortening. And generate API Key to use in Credentials section.

Usage

# Use Class Path at the top of the File.
use Tzsk\ShortenUrl\Facade\GoogleUrl;

# Inside your Controller Method for Shortening.

$short = GoogleUrl::shorten("LONG URL"); # Returns String.
# OR...
$short_data = GoogleUrl::extended()->shorten("LONG URL");
/**
* For extended it will give the full response that google provides.
*/


# Inside your Controller Method for Expanding.
$long = GoogleUrl::expand("SHORT URL"); # Returns String.
# OR...
$long_data = GoogleUrl::extended()->expand("SHORT URL");
/**
* For extended it will give the full response that google provides.
*/

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email mailtokmahmed@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.