-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.php
45 lines (39 loc) · 1.09 KB
/
demo.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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require __DIR__.'/Client.php';
use \DG\API\Photo\Client;
use \DG\API\Photo\PhotoCollection;
use \DG\API\Photo\PhotoItem;
use \DG\API\Photo\Exception as DGAPIPhotoException;
$collection = new PhotoCollection();
$collection
->add( new PhotoItem(100, '/tmp/1.jpg', [
'description' => 'Photo 1 description',
]) )
->add( new PhotoItem(200, '/tmp/2.jpg', [
'description' => 'Photo 2 description',
]) )
->add( new PhotoItem(300, '/tmp/3.jpg', [
'description' => 'Photo 3 description',
]) )
;
$client = new Client('my_cool_key');
try
{
$res = $client->add($collection, $client::OBJECT_TYPE_BRANCH, 100500, $client::ALBUM_CODE_DEFAULT);
} catch (DGAPIPhotoException $e)
{
die( $e->getMessage() );
}
if($res)
{
try
{
$r = $client->upload($collection);
var_dump($r);
} catch (DGAPIPhotoException $e)
{
die( $e->getMessage() );
}
}