pimssas / pims-api-client-php
简单的Pims API PHP客户端
1.0.0
2018-04-17 15:31 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ~5.0|~6.0
- jsor/hal-client: ^3.4
Requires (Dev)
- phpunit/phpunit: ^6.5
This package is auto-updated.
Last update: 2024-09-16 09:34:51 UTC
README
简单的Pims API PHP客户端([文档](http://api.pims.io))。
需求
php >= 7.0
安装
使用Composer进行安装。只需将此行添加到您的composer.json
文件中
"require": {
"pimssas/pims-api-client-php": "dev-master"
}
然后运行
$ composer update
或者直接从命令行安装
$ composer require pimssas/pims-api-client-php:"dev-master"
使用
第一步,您必须创建一个Client
实例
use Pims\Api\Client; use Pims\Api\Exception\ClientException; try { // Minimal setup... $client = new Client( 'https://demo.pims.io/api', 'username', 'password'); // ... or full setup, with language and version $client = new Client( 'https://demo.pims.io/api', 'username', 'password', 'fr', 'v1'); } catch (ClientException $e) { echo $e->getMessage(); }
然后您可以在各种端点上调用它,例如
use Pims\Api\Endpoint; try { // Get the label of the event by ID 2127 $event = $client->getOne( Endpoint::EVENTS, 2127); $label = $event->getProperty('label'); // Get all events occuring in April 2018 $results = $client->getAll( Endpoint::EVENTS, [ 'from_date' => '2018-04-01', 'to_date' => '2018-04-30' ]); $events = $results->getResource('events'); while ($results->hasLink('next')) { $results = $client->getNext($results); $events = array_merge( $events, $results->getResource('events')); } // Get the first 3 channels applied to the event by ID 2127 $promotions = $client->getAll( Endpoint::EVENTS_CHANNELS, [ ':event_id' => 2127, 'page_size' => 3 ]); // Create a new streams group $client->postOne( Endpoint::STREAMS_GROUP, ['label' => 'Streams group test']); // Update the status of the promotion by ID 1437 $client->patchOne( Endpoint::PROMOTIONS, 1437, ['status_id' => 'ENG']); // Delete the venue by ID 234 $client->deleteOne( Endpoint::VENUES, 234); } catch (ClientException $e) { echo $e->getMessage(); }
许可证
版权(c)2010-2019 Pims SAS。在MIT许可证下发布。