-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
75 lines (55 loc) · 1.49 KB
/
example.php
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
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require __DIR__ . '/vendor/autoload.php';
use CropioAPI\Api;
# credentials
$config = require('config.php');
# create Api object
$api = new Api($config);
# check authentication
if(!$api->auth()){
echo 'Authentication error!';
exit(0);
}
/*
# get resource object by ID
$field = $api->single('fields', 1);
# get resource object collection (searching, filtering)
$fields = $api->collection('fields', [
'field_group_id' => 1,
'limit' => 15,
]);
# get all resource object IDs
$field_ids = $api->ids('fields');
# get last changed objects (searching, filtering)
$changes = $api->changes('fields', [
'field_group_id' => 1,
'limit' => 15,
]);
# get last changed object IDs (searching, filtering)
$changes_ids = $api->changes_ids('fields', [
'field_group_id' => 1,
'limit' => 15,
]);
# get multiple resource objects by IDs
$fields = $api->mass_request('fields', [1, 2, 3]);
# get all resource objects (mass_request + ids)
$fields = $api->all('fields');
# create new resource object
$new_field = $api->create('fields', $field);
# multiple create resource objects
$fields = $api->multiple_create('fields', [
$field,
$new_field,
]);
# update resource object
$field = $api->update('fields', 1, $field);
# multiple update resource objects by IDs
$fields = $api->multiple_update('fields', [
1 => $field,
2 => $new_field,
]);
# delete resource object by ID
$api->delete('fields', 1);
# multiple delete resource objects by IDs
$api->multiple_delete('fields', [1, 2]);
//*/