PHP library for Bitly. Code is generated using the OpenAPI spec. See the API reference.
PHP >=8.0
Generate your access token.
Install with Composer:
composer require bitly-api/sdk
Use Composer's autoload:
require_once 'vendor/autoload.php';
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();
}
Generate the code:
composer build
Delete the lib/
directory:
composer clean
Run the tests:
composer test
This package is automatically generated by Jane.