Skip to content

bitly-community/bitly-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

bitly-php

packagist build test

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.