urlr/urlr-php

PHP library for the URLR API.

v0.1 2021-07-26 18:48 UTC

This package is auto-updated.

Last update: 2021-11-26 19:33:23 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

PHP library for the URLR API.

Requirements

PHP 7.3 and later.

Quick install

You can install the bindings via Composer. Run the following command:

composer require urlr/urlr-php guzzlehttp/guzzle http-interop/http-factory-guzzle

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Getting Started

Authentication

$urlr = new \URLR\Client();
$urlr->authenticate('username', 'password');

Reduce a link

$response = $urlr->reduceLink([
    'url' => 'https://mydomain.com/?query=param',
    'team' => 11,
    'folder' => 3,
    'code' => 'my_custom_code'
]);
if ($response->code === 200) {
    $code = $response->url_code;
    echo $code;
}

Get statistics of a link

$response = $urlr->getStatistics([
    'code' => 'XXXXX'
]);
if ($response->code === 200) {
    print_r($response);
}

Advanced usage

We are decoupled from any HTTP messaging client with help by HTTPlug. A list of community provided clients is found here: https://packagist.org/providers/php-http/client-implementation

Using a different HTTP client

composer require urlr/urlr-php symfony/http-client nyholm/psr7

For example, to set up the URLR client with Symfony HTTP client:

use Symfony\Component\HttpClient\HttplugClient;

$urlr = new \URLR\Client(new HttplugClient());

Support

If you need help with this library, please contact us on our website and if you find a bug don't hesitate to create a GitHub issue.