https://github.com/kalprajsolutions/bitly
Laravel Bitly package is developed to for generating bitly short urls with advance features and full control over the short url generation.
https://github.com/kalprajsolutions/bitly
bitly bitly-api bitly-client bitly-v4 kalprajsolutions-bitly laravel laravel-bitly url-shortener url-shortner
Last synced: 5 months ago
JSON representation
Laravel Bitly package is developed to for generating bitly short urls with advance features and full control over the short url generation.
- Host: GitHub
- URL: https://github.com/kalprajsolutions/bitly
- Owner: kalprajsolutions
- License: mit
- Created: 2022-03-17T12:01:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-09T10:32:28.000Z (almost 2 years ago)
- Last Synced: 2025-07-06T13:51:03.039Z (12 months ago)
- Topics: bitly, bitly-api, bitly-client, bitly-v4, kalprajsolutions-bitly, laravel, laravel-bitly, url-shortener, url-shortner
- Language: PHP
- Homepage: https://github.com/kalprajsolutions/bitly
- Size: 23.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Bitly Advanced Package
A laravel package for generating [Bitly](https://bitly.com/) advanced short URLs and BITLINKS.
Bitly is the most widely trusted link management platform in the world. By using the Bitly API, you will exercise the full power of your links through automated link customization, mobile deep linking, and click analytics.
For more information see [BITLY DEV DOCS](https://dev.bitly.com/)
[](https://packagist.org/packages/kalprajsolutions/bitly)
[](https://packagist.org/packages/kalprajsolutions/bitly)
[](https://packagist.org/packages/kalprajsolutions/bitly)
## Requirements
Laravel 5.1 or Later
PHP 7.1 or Later
Bitly [Access Token](https://app.bitly.com/settings/api/ "Access Token")
## Installation
Installation is a quick 3 step process:
1. Download kalprajsolutions/bitly using composer
2. Enable the package in app.php
3. Configure your Bitly credentials
4. (Optional) Configure the package facade
### Step 1: Download kalprajsolutions/bitly using composer
Add **kalprajsolutions/bitly** by executing the command:
```
composer require kalprajsolutions/bitly
```
### Step 2: Enable the package in app.php
Register the Service in: **config/app.php**
```php
KalprajSolutions\Bitly\BitlyServiceProvider::class,
```
### Step 3: Configure Bitly credentials
```
php artisan vendor:publish --provider="KalprajSolutions\Bitly\BitlyServiceProvider"
```
Add this in you **.env** file
```
BITLY_ACCESS_TOKEN=your_secret_bitly_access_token
```
### Step 4 (Optional): Configure the package facade
Register the Bitly Facade in: **config/app.php**
```php
return [
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
// ...
'Bitly' => KalprajSolutions\Bitly\Facade\Bitly::class,
],
];
```
## Quick Usage
```php
$url = app('bitly')->short('https://www.example.com/'); // http://bit.ly/abcdefg
```
Or if you want to use facade, add this in your class after namespace declaration:
```php
use Bitly;
```
Then you can use it directly by calling `Bitly::` like:
```php
$url = Bitly::short('https://www.example.com/'); // http://bit.ly/abcdefg
```
In quick usage you can also use Proxy to short the url asap using `->proxy()`
```php
$url = Bitly::proxy('user:pass@1.1.1.1:80')->short('https://www.example.com/'); // http://bit.ly/abcdefg
```
## Advance Usage
This Bitly package allow you to use advance bitlink attributes to customize bitly urls and proxies.
#### Guarding Attributes
> Note: While using attribues you will have to provide `->url()` and `->get()` to retrive short url!
**URL**
You will have to provide long URL to this function which will be used to shorten the url.
```php
$url = Bitly::url('http://example.com')->get(); // http://bit.ly/nHcn3
```
**TITLE**
Its a short description that appears in the Bitly UI.
You can now set the title of the URL which you are shortning by passing title in title function
```php
$url = Bitly::url('http://example.com')
->title('This will be the title')
->get();
```
**PROXY**
Pass an associative array to specify HTTP proxies for specific URI schemes (i.e., "http", "https"). Provide a no key value pair to provide a list of host names that should not be proxied to.
> Note: You can provide proxy URLs that contain a scheme, username, and password. For example, "http://user:pass@localhost:8125".
```php
$url = Bitly::url('http://example.com')
->proxy('user:pass@localhost:8125')
->get();
```
OR
```php
$url = Bitly::url('http://example.com')
->proxy([
'http' => 'http://localhost:8125', // Use this proxy with "http"
'https' => 'http://localhost:9124', // Use this proxy with "https"
])
->get();
```
**TAGS**
Set multiple tags with tags attributes. Tags must be provided in array.
```php
$url = Bitly::url('http://example.com')
->tags([
'First Tag',
'Second Tag',
])->get();
```
**GUID**
guid can be used to set your group id. GUID Identifies a group of users in your account. Every user will belong to at least one group within an organization. Most actions on our API will be on behalf of a group. Always verify your default group in Bitly and specify a group in the call with `->guid()` attribute.
```php
$url = Bitly::url('http://example.com')
->guid('Ba1bc23dE4F')
->get();
```
**DOMAIN**
Customizing the domain requires that you have a custom domain attached to your Bitly account. The default value is bit.ly.
To brand your short links use domain attribute. Premium Bitly customers can set custom domain added in dashboard with `->domain()` . This is only for Premium Bitly Customers
```php
$url = Bitly::url('http://example.com')
->domain('custom.com')
->get();
```