urlr / urlr-php
PHP library for the URLR API.
Requires
- php: >=7.3
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- php-http/discovery: *
- php-http/message: *
- psr/http-client: *
- psr/http-client-implementation: *
- psr/http-factory: *
Requires (Dev)
- phpstan/phpstan: ^1
README
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
The Guzzle client will automatically be found with the help of php-http/discovery
package. If you prefer to specify a custom HTTP client to use, please read the Advanced usage section.
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\Psr18Client; $urlr = new \URLR\Client(new Psr18Client());
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.