Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Bitly Api Laravel Package

hpatoio/bitly-api

Unmaintained PHP Bitly API client built on Guzzle. Provides a Bitly\Client for calling endpoints (e.g., Highvalue), supports custom cURL options like timeouts, and allows attaching Guzzle plugins (e.g., logging). Symfony2 integration mentioned.

View on GitHub
Deep Wiki
Context7

BitlyApi

This package is not maintained

Check phplicengine/bitly as a possible replacement.

Build Status Total Downloads Latest Stable Version SensioLabsInsight

PHP Library based on Guzzle to consume Bit.ly API.

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.

An integration with Symfony2 is available as well.

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.

Installation

The recommended way to install this library is through Composer. For information about Composer and how to install in look here.

New project

From the command line run

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

Existing project

Move into your project directory and run

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

or add to your composer.json

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

and run

./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:


$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.

Examples:

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

Available methods

At the moment the library supports these APIs:

Behat

You need to copy Behat default configuration file and enter your access_token option there.

$ 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

$ bin/behat

Integrations

A Symfony2 bundle that integrate this library is available here

Attach Guzzle plugin

Here you can see how to attach Guzzle Log plug to your client and save all your requests to a file.

NB: To run this script you need monolog/monolog

<?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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky