Skip to content

Latest commit

 

History

History
89 lines (54 loc) · 2.4 KB

README.md

File metadata and controls

89 lines (54 loc) · 2.4 KB

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