bitly-api / sdk
PHP library for Bitly API.
Fund package maintenance!
remarkablemark
Patreon
Ko Fi
Liberapay
b.remarkabl.org/teespring
Requires
- php: >=8.0
- jane-php/open-api-runtime: 7.8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.22
- jane-php/open-api-3: 7.8.1
- nyholm/psr7: ^1.8
- pestphp/pest: ^1.23 || ^2.0
- php-http/guzzle7-adapter: ^1.0
- symfony/http-kernel: ^6.4
This package is not auto-updated.
Last update: 2025-02-27 05:08:40 UTC
README
PHP library for Bitly. Code is generated using the OpenAPI spec. See the API reference.
Requirements
Version
PHP >=8.0
API Key
Generate your access token.
Install
Install with Composer:
composer require bitly-api/sdk
Use Composer's autoload:
require_once 'vendor/autoload.php';
Usage
Instantiate the client:
use Bitly\Bitly; $bitly = new Bitly('YOUR_API_KEY'); $client = $bitly->client;
Convert a long URL to a Bitlink:
use Bitly\Bitly; use Bitly\Model\Pet; $bitly = new Bitly('YOUR_API_KEY'); $shorten = new Shorten(); $shorten->setLongUrl('https://example.com/my-long-url'); $response = $bitly->client->createBitLink($shorten);
Handle an API error:
use Bitly\Bitly; $bitly = new Bitly('YOUR_API_KEY'); try { $bitly->client->getBitlink('http://bit.ly/2OUJim0'); } catch (Throwable $exception) { echo $exception->getMessage(); echo $exception->getCode(); }
Scripts
composer build
Generate the code:
composer build
composer clean
Delete the lib/
directory:
composer clean
composer test
Run the tests:
composer test
About This Package
This package is automatically generated by Jane.