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

This package is auto-updated.

Last update: 2024-11-20 21:17:08 UTC


README

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