PHP library to consume bit.ly API

1.0.2 2017-01-25 19:52 UTC

This package is not auto-updated.

Last update: 2024-12-21 20:30:32 UTC


README

Build Status Latest Stable Version

PHP library to consume bit.ly API

Installation

The recommended way to install this library is through Composer.

composer require gabrielkaputa/bitly

Usage

First of all, create a bit.ly account if you don't have one already.

If all you need to do is to create shortlinks on behalf of a single user or site, all you need is to get your generic access token. When done, you can create shortlinks like this:

require_once("vendor/autoload.php");

$bitly = \GabrielKaputa\Bitly::withGenericAccessToken(GENERIC_ACCESS_TOKEN);
$short_url = $bitly->shortenUrl($long_url);

Another option is when you are working with multiple end-users or to pull any information on a user level for your own account. In this case you will need to register your application to get your CLIENT_ID and CLIENT_SECRET. When done, you can create shortlinks like this:

require_once("vendor/autoload.php");

$bitly = \GabrielKaputa\Bitly::withCredentials(CLIENT_ID, CLIENT_SECRET, USERNAME, PASSWORD);
$short_url = $bitly->shortenUrl($long_url);