bramalho / laravel-bitly-client
Laravel Bitly Client Package
Installs: 2 204
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=7.1.3
- guzzlehttp/guzzle: ^6.3
- laravel/framework: ^5.5
This package is auto-updated.
Last update: 2024-11-13 02:27:47 UTC
README
Laravel Bitly Client is a Laravel package that provide a simple client for the Bitly URL shorten.
Installation
Install the package
composer require bramalho/laravel-bitly-client
Add the service provider in config/app.php
BRamalho\LaravelBitlyClient\LaravelBitlyClientServiceProvider::class,
Publish the configs
php artisan vendor:publish --provider 'BRamalho\LaravelBitlyClient\LaravelBitlyClientServiceProvider'
Add your Bitly credentials in your .env
file
BITLY_LOGIN=your_api_login BITLY_API_KEY=your_api_key
Usage
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use BRamalho\LaravelBitlyClient\BitlyClient; use BRamalho\LaravelBitlyClient\InvalidCredentialsException; use BRamalho\LaravelBitlyClient\UnableToGenerateURLException; class HomeController extends Controller { /** * @return array * @throws InvalidCredentialsException * @throws UnableToGenerateURLException */ public function index() { $bitlyClient = new BitlyClient(); return $bitlyClient->generate('https://brunoramalho.com'); } }
This will return something like:
[ 'url' => 'http://bit.ly/2KiTbFW', 'hash' => '2KiTbFW', 'global_hash' => '2KiTbWs', 'long_url' => 'https://brunoramalho.com/' 'new_hash' => 0 ]
License
The Laravel Bitly Client is open-sourced software licensed under the MIT license.