codehaveli / bitly-php
Bitly PHP SDK by Codehaveli uses the functionality of Bitly API version 4. This package is in initial release and have very less feature compared to main Bitly API.
dev-master
2020-09-20 11:45 UTC
Requires
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- overtrue/phplint: ^2.0
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-11-20 21:17:08 UTC
README
Description
A PHP wrapper for the bit.ly API. This package use Bitly API version v4.
Installation
Install via composer
composer require codehaveli/bitly-php:dev-master --prefer-source
Usage
<?php require 'vendor/autoload.php'; use Codehaveli\Bitly; use Codehaveli\Exceptions\BitlyErrorException; // First setup your credentials provided by Bitly $accessToken = "ACCESS_TOKEN_FROM_BITLY"; $guid = "GUID_FROM_BITLY"; Bitly::init($accessToken, $guid);
Once credentials are set you can use available resources.
Resources availables:
- Link
- Available methods:
getUrl
- Available methods:
Link
<?php use Codehaveli\Bitly; use Codehaveli\Exceptions\BitlyErrorException; Bitly::init($access_token, $guid); $link = Bitly::link(); try { $shortLink = $link->getUrl("https://www.codehaveli.com/"); // https://bit.ly/3lF0yKR } catch (BitlyErrorException $e) { $code = $e->getCode(); $message = $e->getMessage(); }
Terms of Use
This is not a Official SDK of Bitly Please read privacy and terms of service of Bitly before use.
Other Resource
- Wordpress Plugin by Codehaveli Codehaveli Bitly URL Shortener
- Bitly API Documentation
- Codehaveli Blog