-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathAlbum.php
164 lines (153 loc) · 5.19 KB
/
Album.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
namespace Imgur\Api;
/**
* CRUD for Albums.
*
* @see https://api.imgur.com/endpoints/album
*
* @author Adrian Ghiuta <adrian.ghiuta@gmail.com>
*/
class Album extends AbstractApi
{
/**
* Get information about a specific album.
*
* @param string $albumId
*
* @see https://api.imgur.com/endpoints/album#album
*
* @return array Album (@see https://api.imgur.com/models/album)
*/
public function album($albumId)
{
return $this->get('album/' . $albumId);
}
/**
* Return all of the images in the album.
*
* @param string $albumId
*
* @see https://api.imgur.com/endpoints/album#album-images
*
* @return array Array of Image (@see https://api.imgur.com/models/image)
*/
public function albumImages($albumId)
{
return $this->get('album/' . $albumId . '/images');
}
/**
* Get information about an image in an album, any additional actions found in Image Endpoint will also work.
*
* @param string $albumId
* @param string $imageId
*
* @see https://api.imgur.com/endpoints/album#album-image
*
* @return array Image (@see https://api.imgur.com/models/image)
*/
public function albumImage($albumId, $imageId)
{
return $this->get('album/' . $albumId . '/image/' . $imageId);
}
/**
* Create a new album. Optional parameter of ids[] is an array of image ids to add to the album (if you're authenticated with an account).
* This method is available without authenticating an account, and may be used merely by sending "Authorization: Client-ID {client_id}"
* in the request headers. Doing so will create an anonymous album which is not tied to an account.
* Adding images to an anonymous album is only available during image uploading.
*
* @param array $data
*
* @see https://api.imgur.com/endpoints/album#album-upload
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function create($data)
{
return $this->post('album', $data);
}
/**
* Update the information of an album.
* For anonymous albums, {album} should be the deletehash that is returned at creation.
*
* @param string $deletehashOrAlbumId
* @param array $data
*
* @see https://api.imgur.com/endpoints/album#album-update
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function update($deletehashOrAlbumId, $data)
{
return $this->post('album/' . $deletehashOrAlbumId, $data);
}
/**
* Delete an album with a given ID. You are required to be logged in as the user to delete the album.
* Takes parameter, ids[], as an array of ids and removes from the labum.
* For anonymous albums, {album} should be the deletehash that is returned at creation.
*
* @param string $deletehashOrAlbumId
*
* @see https://api.imgur.com/endpoints/album#album-delete
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function deleteAlbum($deletehashOrAlbumId)
{
return $this->delete('album/' . $deletehashOrAlbumId);
}
/**
* Favorite an album with a given ID. The user is required to be logged in to favorite the album.
*
* @param string $albumId
*
* @see https://api.imgur.com/endpoints/album#album-favorite
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function favoriteAlbum($albumId)
{
return $this->post('album/' . $albumId . '/favorite');
}
/**
* Sets the images for an album, removes all other images and only uses the images in this request.
* (Not available for anonymous albums.).
*
* @param string $albumId
*
* @see https://api.imgur.com/endpoints/album#album-set-to
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function setAlbumImages($albumId, array $imageIds)
{
return $this->post('album/' . $albumId, ['ids' => implode(',', $imageIds)]);
}
/**
* Takes parameter, ids[], as an array of ids to add to the album.
* (Not available for anonymous albums. Adding images to an anonymous album is only available during image uploading.).
*
* @param string $albumId
*
* @see https://api.imgur.com/endpoints/album#album-add-to
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function addImages($albumId, array $imageIds)
{
return $this->post('album/' . $albumId . '/add', ['ids' => implode(',', $imageIds)]);
}
/**
* Takes parameter, ids[], as an array of ids and removes from the album.
* For anonymous albums, $deletehashOrAlbumId should be the deletehash that is returned at creation.
*
* @param string $deletehashOrAlbumId
*
* @see https://api.imgur.com/endpoints/album#album-remove-from
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function removeImages($deletehashOrAlbumId, array $imageIds)
{
return $this->delete('album/' . $deletehashOrAlbumId . '/remove_images', ['ids' => implode(',', $imageIds)]);
}
}