Giter Club home page Giter Club logo

api-php-client's Introduction

NOTE: This is currently a work in progress and is designed as just one example on how to interact with the Shutterstock API using PHP.

Shutterstock API PHP Client

PHP Client is a single file library which provides an easy way to interact with the Shutterstock Inc. API http://api.shutterstock.com. You will need an API username and key from Shutterstock with the appropriate permissions in order to use this client.

Get Started:

Include "ShutterstockApiClient.php" in your PHP script and initialize class.

require_once('ShutterstockApiClient.php');

$sapi = new ShutterstockApiClient();

**Note:** Make sure to replace below values in the class with your credentials.

//customer credentials     
private static $customer_username      = 'XXXXXX';
private static $customer_password       = 'XXXXX';

//basic auth info
private static $auth_username = 'XXXXX';
private static $auth_key      = 'XXXXX'; 

Below are some examples of how to use this client to interact with Shutterstock Inc. API:

Get category list

$categories = $sapi->getCategories();

Search for images by keywords and various filters

$search_result = $sapi->search('dog', $filters);

There are many filters supported while searching for Shutterstock images catalog. You need to pass these filters in $filters array as key-value pair.

all boolean A flag indicating that all search results should be returned. Accepted values are 1 for true and 0 for false.
category_id int An integer category id to search within. Required when searchterm, photographer_name, submitter_id, and color are not provided.
color html color A color to search for. Required when searchterm, category_id, photographer_name, and submitter_id are not provided. Accepted values are 6-character HTML hex colors from '000000' to 'FFFFFF', with or without number sign.
commercial_only boolean A flag indicating that only images which are available for commercial use should be returned; no images for editorial use only. Accepted values are 1 for true and 0 for false.
enhanced_only boolean A flag indicating that only images with enhanced licenses available should be returned. Accepted values are 1 for true and 0 for false.
exclude_keywords str A string of space-separated keywords to exclude from your search.
language language The 2-letter language code that the query and desired results should be in. If not specified, use an eligible language from the Accept-Language header. Otherwise, defaults to "en". Accepted values are: 'en', 'zh', 'nl', 'fr', 'de', 'it', 'jp', 'pt', 'ru', 'es', 'cs', 'hu', 'tr', 'pl'. Default is 'en'.
model_released boolean A flag indicating that only model-released photos should be returned. Accepted values are 1 for true and 0 for false.
orientation enum Whether a photograph is wider than it is tall, or taller than it is wide. Accepted values are: 'all', 'horizontal', 'vertical'. Default is 'all'.
page_number nonnegative integer Which page of results is wanted Accepted values are nonnegative integers.
photographer_name str The username of a specific submitter whose work you want to search within. Required when searchterm, category_id, submitter_id, and color are not provided.
safesearch boolean A flag indicating that only images suitable for all ages should be returned. Accepted values are 1 for true and 0 for false. Default is '1'.
search_group enum A media type to search within. Accepted values are: 'photos', 'illustrations', 'vectors', 'all'. Default is 'all'.
searchterm str A string of space-separated keywords to search for. Required when category_id, photographer_name, submitter_id, and color are not provided. Example: 'cat'.
sort_method enum How the results should be sorted. Accepted values are: 'newest', 'oldest', 'popular', 'random', 'relevance'. Default is 'popular'.
submitter_id int The integer id of a specific submitter whose work you want to search within. Required when searchterm, category_id, photographer_name, and color are not provided.

Get information about customer

$customer_info = $sapi->getCustomerUserInfo();

Get list of all customer lightboxes

$lightboxes = $sapi->getLightboxes();

Add new lightbox

$add_lightbox = $sapi->addLightbox(lightbox_name); 

Add image to particular lightbox

$add_lightbox_image = $sapi->addImageToLightbox(lightbox_id, image_id);

Remove image from particular lightbox

$remove_lightbox_image = $sapi->deleteImageFromLightbox(lightbox_id, image_id);

Get all images from particular lightbox

$lightbox_details = $sapi->getLightbox(lightbox_id);

Delete particular lightbox

$delete_lightbox = $sapi->deleteLightbox(lightbox_id);

Get list of all subscriptions for loggedin customer

$subscription = $sapi->getSubscriptions();

Get download history for loggedin customer

$downloads = $sapi->getDownloads();

Download an image using a subscription

$download = $sapi->downloadImage(image_id, subscription_id, size, format, meta_data);

api-php-client's People

Contributors

bbaisley avatar

Watchers

James Cloos avatar Xin Gao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.