shutterstock / api
Installs: 23 661
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 23
Forks: 5
Open Issues: 6
Requires
- php: >=5.6
- guzzlehttp/guzzle: ^6.1
- psr/log: ^1.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpunit/phpunit: ^5.0
This package is not auto-updated.
Last update: 2024-11-15 19:50:29 UTC
README
PHP client that utilizes Guzzle to interact with the Shutterstock API.
Installation
Use Composer to install the dependencies.
$ composer require shutterstock/api
Usage
Instantiating the client requires passing in your client id and secret, which you can register for on the Shutterstock Developers site.
<?php require_once __DIR__ . '/vendor/autoload.php'; $client = new Shutterstock\Api\Client($clientId, $clientSecret);
Interacting with the different endpoints is as simple as reading the API documentation. There are two main methods of the client to deal with - Client::get
and Client::post
- which take an endpoint as their first argument and the client parameters as the second.
// perform an image search for puppies $client->get('images/search', array('query' => 'puppies')); // retrieve details for a handful of image ids $client->get('images', array('id' => array(1, 2, 3))); // create a lightbox $client->post('images/collections', array('name' => 'Lightbox Name Here'));
Each request will return a PSR-7 response object, which you can read about on the Guzzle/PSR7 repo. The response object bodies have been decorated with a JsonSerializable interface to allow easier handling of the default API responses.
$imageResponse = $client->get('images', array('id' => array(1, 2, 3))); if ($imageResponse->getStatusCode() != 200) { // error handler } $images = $imageResponse->getBody()->jsonSerialize()['data']; // etc
If your application is setup to handle async CURL requests, you can also make Client::getAsync
and Client::postAsync
calls, which return Guzzle Promises.
For more examples and a demo application using this client, see [LINK HERE].
License
Apache 2.0 © 2016-2017 Shutterstock Images, LLC