Shorten URLs in Your Laravel App with the Cuttly Package
Published on by Paul Redmond
Cuttly Service is a Laravel Package that provides a convenient wrapper to the Cuttly API. It provides link shortening, editing, and statistics around shortened URLs that you create in your Laravel application:
use Slvler\Cuttly\Facades\Cuttly; Cuttly::short(['short' => 'google.com']);/*{ "url": { "status": 7, "fullLink": "http://google.com", "date": "2023-08-07", "shortLink": "https://cutt.ly/ewdVijlY", "title": "Google" }}*/
You can conveniently retrieve stats for a shortened URL using the stats()
method:
use Slvler\Cuttly\Facades\Cuttly; Cuttly::stats(['stats' => 'cutt.ly/ewdVijlY']);/*{ "stats": { "status": 1, "clicks": 0, "date": "2023-08-07", "title": "Google", "fullLink": "http://google.com", "shortLink": "https://cutt.ly/ewdVijlY", "facebook": 0, "twitter": 0, "pinterest": 0, "instagram": 0, "googlePlus": 0, "linkedin": 0, "rest": 0, "devices": {}, "refs": {}, "bots": "Insufficient subscription level" }}*/
You can sign up and get familiar with the Cutt.ly API by checking out the API documentation. To get started with the source code, you can check it out on GitHub at slvler/laravel-url-shortener.