gabrielkaputa / bitly
PHP library to consume bit.ly API
Installs: 65 466
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- nategood/httpful: ^0.2.20
Requires (Dev)
- phpunit/phpunit: ^5.3
This package is not auto-updated.
Last update: 2024-12-21 20:30:32 UTC
README
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);