2017 © Pedro Peláez
 

library bitly-api

PHP Library based on Guzzle to consume Bit.ly API

image

hpatoio/bitly-api

PHP Library based on Guzzle to consume Bit.ly API

  • Tuesday, February 21, 2017
  • by hpatoio
  • Repository
  • 6 Watchers
  • 29 Stars
  • 203,251 Installations
  • Gherkin
  • 1 Dependents
  • 0 Suggesters
  • 10 Forks
  • 2 Open issues
  • 14 Versions
  • 4 % Grown

The README.md

BitlyApi

This package is not maintained

Check phplicengine/bitly as a possible replacement., (*1)

Build Status Total Downloads Latest Stable Version SensioLabsInsight, (*2)

PHP Library based on Guzzle to consume Bit.ly API., (*3)

The biggest advantage in using Guzzle is that you can easely attach Guzzle plugins to your client. Here, for example,you can see how to attach the log plugin and write all your requests to a file., (*4)

An integration with Symfony2 is available as well., (*5)

Versions

  • branch master follows psr4 standards and get 2.x tags
  • branch psr0 follows, of course, psr0 standards and get 1.x tags - No new features only bugfix

This project follow semantic versioning., (*6)

Installation

The recommended way to install this library is through Composer. For information about Composer and how to install in look here., (*7)

New project

From the command line run, (*8)

./composer create-project hpatoio/bitly-api your_prj_dir '~2.0'

Existing project

Move into your project directory and run, (*9)

./composer require hpatoio/bitly-api '~2.0'

or add to your composer.json, (*10)

{
    ...
    "require": {
        ...
        "hpatoio/bitly-api": "~2.0"
    }
}

and run, (*11)

./composer update

Usage

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

# To find your bitly access token see here https://bitly.com/a/oauth_apps
$my_bitly = new \Hpatoio\Bitly\Client("insert_here_your_bitly_api_access_token");

$response = $my_bitly->Highvalue(array("limit" => 3));

print_r($response);

cURL options

It might be that bit.ly is unreachable and you want to set a specific timeout. Just set the cURL timeout options in the client:, (*12)


$my_bitly = new \Hpatoio\Bitly\Client("insert_here_your_bitly_api_access_token"); // set cURL timeout, you can specify any cURL options $my_bitly->setConfig(array( 'curl.options' => array( CURLOPT_TIMEOUT => 2, CURLOPT_CONNECTTIMEOUT => 2 ) )); $response = $my_bitly->Highvalue(array("limit" => 3)); print_r($response);

Methods names

To get the method name remove "v3" from the API url and camelize the other words removing the slashes., (*13)

Examples:, (*14)

  • /v3/highvalue -> Highvalue
  • /v3/realtime/hot_phrases -> RealtimeHot_phrases
  • /v3/link/content -> LinkContent

Available methods

At the moment the library supports these APIs:, (*15)

Behat

You need to copy Behat default configuration file and enter your access_token option there., (*16)

$ cp behat.yml.dist behat.yml

Now open behat.yml and change the string your_bitly_access_token_here with your access token. Run the suite typing, (*17)

$ bin/behat

Integrations

A Symfony2 bundle that integrate this library is available here, (*18)

Attach Guzzle plugin

Here you can see how to attach Guzzle Log plug to your client and save all your requests to a file., (*19)

NB: To run this script you need monolog/monolog, (*20)

<?php
// This file is generated by Composer
require_once 'vendor/autoload.php';

use Guzzle\Log\MessageFormatter;
use Guzzle\Log\MonologLogAdapter;
use Guzzle\Plugin\Log\LogPlugin;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

$logger = new Logger('client');
$logger->pushHandler(new StreamHandler('/tmp/bitly_guzzle.log'));
$adapter = new MonologLogAdapter($logger);
$logPlugin = new LogPlugin($adapter, MessageFormatter::DEBUG_FORMAT);

# To find your bitly access token see here https://bitly.com/a/oauth_apps
$my_bitly = new \Hpatoio\Bitly\Client("your_bitly_access_token");
$my_bitly->addSubscriber($logPlugin);

$response = $my_bitly->Highvalue(array("limit" => 3));

print_r($response);

Now in /tmp/bitly_guzzle.log you can see all your requests., (*21)

The Versions

21/02 2017

dev-master

9999999-dev http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

21/02 2017

2.0.5

2.0.5.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

18/01 2017

2.0.4

2.0.4.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

27/07 2016

2.0.3

2.0.3.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

21/09 2015

dev-travis-use-cache

dev-travis-use-cache http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

21/09 2015

2.0.2

2.0.2.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

06/09 2014

2.0.1

2.0.1.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

26/08 2014

dev-guzzle4

dev-guzzle4 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

04/06 2014

2.0.0

2.0.0.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api behat guzzle bitly

03/06 2014

dev-psr0

dev-psr0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api guzzle bitly

03/06 2014

1.0.1

1.0.1.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api guzzle bitly

12/04 2014

1.0

1.0.0.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api guzzle bitly

03/12 2013

0.4

0.4.0.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api guzzle bitly

19/11 2013

0.1

0.1.0.0 http://www.iliveinperego.com/

PHP Library based on Guzzle to consume Bit.ly API | Not all API method are mapped yes

  Sources   Download

CC-BY-SA-3.0

The Requires

 

The Development Requires

api guzzle bitly