Skip to content

gabrielkaputa/bitly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitly

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);

About

PHP library to consume bit.ly API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages