setono/kraken-io-php-sdk
最新稳定版本:v1.1.1
Composer 安装命令:
composer require setono/kraken-io-php-sdk
包简介
A PHP SDK for the kraken.io API
README 文档
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);
统计信息
- 总下载量: 29.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-21