setono / kraken-io-php-sdk
A PHP SDK for the kraken.io API
Installs: 29 310
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 2
Requires
- php: >=7.3
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- thecodingmachine/safe: ^1.0
- webimpress/safe-writer: ^2.0
- webmozart/assert: ^1.7
Requires (Dev)
- ext-json: *
- kriswallsmith/buzz: ^1.1
- nyholm/psr7: ^1.3
- phpunit/phpunit: ^9.4
- setono/code-quality-pack: ^1.4
This package is auto-updated.
Last update: 2024-11-15 16:21:37 UTC
README
A PHP SDK for the Kraken.io API.
Installation
Download
Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:
$ composer require setono/kraken-io-php-sdk
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Install HTTP client
This library is HTTP client agnostic so you need to provide your own PSR18 HTTP client implementation. If you don't want to bother with this, you can just do this:
$ composer require kriswallsmith/buzz nyholm/psr7
This will install the PSR18 HTTP client, Buzz and HTTP message factories used to create requests, responses, and streams.
Usage
Upload file via URL and wait for a response
<?php use Setono\Kraken\Client\Client; use Setono\Kraken\Client\Response\WaitResponse; $client = new Client('Your API key', 'Your API secret'); /** @var WaitResponse $response */ $response = $client->url('https://www.your-domain.com/your/image.jpg', true); /** @var SplFileInfo $optimizedImageFile */ $optimizedImageFile = $response->getFile();
Get user status
<?php use Setono\Kraken\Client\Client; use Setono\Kraken\Client\Response\UserStatusResponse; $client = new Client('Your API key', 'Your API secret'); /** @var UserStatusResponse $response */ $response = $client->status(); echo sprintf('Quota total: %s', $response->getQuotaTotal()); echo sprintf('Quota used: %s', $response->getQuotaUsed()); echo sprintf('Quota remaining: %s', $response->getQuotaRemaining());
I want to use my own HTTP client implementation and message factories
You can inject your own implementations when instantiating the client:
<?php use Setono\Kraken\Client\Client; $client = new Client('Your API key', 'Your API secret', $httpClient, $httpRequestFactory, $httpStreamFactory);