-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.php
More file actions
63 lines (42 loc) · 1.75 KB
/
example.php
File metadata and controls
63 lines (42 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require __DIR__ . '/vendor/autoload.php';
// Create instance of REST client
$presto = new Presto\Presto();
// Create instance to handle responses
// Pass false (don't extract response data) parameter to have
// it return full response headers and debugging information
$response = new Shutterstock\Response(false);
// Create instance of Shutterstock API client
$api = new Shutterstock\Api('<api username>','<api key>', $presto, $response);
//
// End points not requiring user login //
//
// Test connection
print_r($api->test());
// Get categories list
$categories = $api->categories();
// Create instance to access Image end points
$images = new Shutterstock\Images($api);
$search_result = $images->search('dog');
$similar_images = $images->similar(15484942, array('sort_method'=>'relevance') );
$image_info = $images->get(126709091);
$suggest_words = $images->suggestWords(array(126709091, 127334102, 126312287, 126312281));
//
// Login as a Shutterstock user //
//
// Should only authUser once per session
// auth token should be extracted and retained
$auth_info = $api->authUser('<username>','<password>');
// Instead of authing again, set user with auth token
//$api->setUser('<username>','<auth token>');
// Auth token is automatically used when needed on API requests
$user_info = $api->userInfo();
$subscriptions = $api->subscriptions();
// Get download URL for downloading and image
//$download_info = $images->purchase('<subscription_id>', '<image id>', 'small');
// Get list of lightboxes for user
$lightboxes = $api->lightboxes();
// Create Lightbox instance to interact with a lightbox
$lightbox_api = new Shutterstock\Lightbox($api, '<lightbox ID>');
$lb_contents = $lightbox_api->contents();
$lb_contents_ext = $lightbox_api->contentsExtended();