2017 © Pedro Peláez
 

library api

image

shutterstock/api

  • Wednesday, November 29, 2017
  • by jacobemerick
  • Repository
  • 6 Watchers
  • 5 Stars
  • 519 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 3 Versions
  • 56 % Grown

The README.md

Demo Client for Shutterstock API

PHP client that utilizes Guzzle to interact with the Shutterstock API., (*1)

Build Status Code Climate Test Coverage Scrutinizer Code Quality, (*2)

Installation

Use Composer to install the dependencies., (*3)

$ 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., (*4)

<?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., (*5)

// 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., (*6)

$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., (*7)

For more examples and a demo application using this client, see [LINK HERE]., (*8)

License

Apache 2.0 © 2016-2017 Shutterstock Images, LLC, (*9)

The Versions

29/11 2017

dev-master

9999999-dev

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

29/11 2017

dev-docs/2017-11-29

dev-docs/2017-11-29

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

04/03 2016

1.0.0

1.0.0.0

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires