Skip to content

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.

License

Notifications You must be signed in to change notification settings

codehaveli/bitly-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitly PHP SDK by Codehaveli

GitHub Workflow Status Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads License

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

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

  1. Wordpress Plugin by Codehaveli Codehaveli Bitly URL Shortener
  2. Bitly API Documentation
  3. Codehaveli Blog