szeidler / fotoweb-php-sdk
Fotoweb by fotoware.com PHP SDK
2.1.5
2024-05-23 15:55 UTC
Requires
- php: >=7.4
- guzzlehttp/guzzle-services: ^1.1
- kamermans/guzzle-oauth2-subscriber: ^1.0
- psr/http-message: ^1.1 || ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.0 || ^10.0
This package is auto-updated.
Last update: 2024-09-20 20:21:18 UTC
README
Fotoweb PHP SDK利用guzzle-services,方便地与Fotoware的 FotoWeb RESTful API集成。
需求
- PHP 7.4或更高版本
- Composer
- Guzzle
安装
将Fotoweb PHP SDK添加为composer依赖。
composer require szeidler/fotoweb-php-sdk:^2.0
使用方法
根据资产的资源URL返回资产表示。
use Fotoweb\FotowebClient; // Using the legacy API code method. $client = new FotowebClient([ 'baseUrl' => 'https://demo.fotoware.com', 'authType' => 'token', 'apiToken' => 'yourapi token', ]); // Using oAuth2 with client credentials (Web API) $client = new FotowebClient([ 'baseUrl' => 'https://demo.fotoware.com', 'authType' => 'oauth2', 'grantType' => 'client_credentials', 'clientId' => 'your client id', 'clientSecret' => 'your client secret', 'persistenceProvider' => new \kamermans\OAuth2\Persistence\NullTokenPersistence(), ]); // Using oAuth2 with authorization_code (Web API) $client = new FotowebClient([ 'baseUrl' => 'https://demo.fotoware.com', 'authType' => 'oauth2', 'grantType' => 'authorization_code', 'codeVerifier' => 'PKCE code verifier', 'redirectUri' => 'your oauth2 redirect callback', 'clientId' => 'your client id', 'clientSecret' => 'your client secret', 'persistenceProvider' => new \kamermans\OAuth2\Persistence\NullTokenPersistence(), ]); $href = '/fotoweb/archives/5013-Demo%20assets/Artwork/Coffee%20from%20DAM/240x400.jpg.info'; $asset = $client->getAsset(['href' => $href]); print $asset->offsetGet('filesize');
测试
此SDK将PHPUnit作为composer require-dev
。将phpunit.xml.dist
复制到phpunit.xml
,并填写您的API测试凭据。
注意:当前SDK不使用模拟响应,而是实际调用API。
./vendor/bin/phpunit -c phpunit.xml
鸣谢
Stephan Zeidler为Ramsalt Lab AS
许可协议
MIT许可协议(MIT)