Introducing the T.LY Laravel URL Shortener API Package
When building web applications, it’s often necessary to provide users with shortened links—be it for social sharing, measuring clicks, or simply tidying up long URLs. The T.LY API makes it simple and fast to generate short, trackable URLs. Thanks to the new TLY Laravel package, integrating this functionality into your PHP Laravel project is now easier than ever.
Why Use the T.LY API for URL Shortening?
T.LY is a simple URL shortener that goes beyond just shrinking links. By leveraging the T.LY API, you can:
- Generate short URLs with ease.
- Access analytics and click metrics.
- Organize and manage your shortened URLs through tags and dashboards.
- Maintain brand consistency by using custom domains.
Integrating all this functionality into your Laravel application can give your users a much more polished experience. With the tly/laravel-url-shortener-api
package, it’s a breeze.
Getting Started
Create an API Key
- Register a T.LY Account
- Create an API Token
Installation
Install via Composer:
composer require tly/laravel-url-shortener-api
Publish the configuration:
php artisan vendor:publish --provider="TLY\\LaravelUrlShortener\\TLYServiceProvider" --tag=config
Set your API token in .env
:
TLY_API_TOKEN=your_api_token_here
Examples
Create a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::create([
'long_url' => 'https://example.com',
'description' => 'Example Link',
]);
Update a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::update([
'short_url' => 'https://t.ly/123',
'long_url' => 'https://new-destination.com',
'description' => 'Updated Link Description',
'expire_at_datetime' => '2035-12-31 23:59:59',
]);
Delete a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::delete('https://t.ly/123');
Get a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::get('https://t.ly/123');
Get the stats for a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::stats('https://t.ly/123');
Thanks to the TLY Laravel URL Shortener API package, you can seamlessly integrate powerful URL shortening and analytics features into your Laravel application. Whether you need quick, branded short links, detailed statistics, or tagging capabilities, the T.LY API has you covered.
For more details, visit the T.LY documentation and start exploring all the features available at your fingertips.
Related Posts
Tim Leland
Ready to improve how you manage links?
T.LY URL Shortener makes long links look cleaner and easier to share! Add your own Custom Domains to personalize your brand. Create Smart Links to customize a URL's destination. Generate QR codes to promote your business.
Sign Up for Free