@@ -73,14 +73,171 @@ public function addTags($photoId, $tags)
7373 ], true );
7474 }
7575
76- //flickr.photos.delete
77- //flickr.photos.getAllContexts
78- //flickr.photos.getContactsPhotos
79- //flickr.photos.getContactsPublicPhotos
80- //flickr.photos.getContext
81- //flickr.photos.getCounts
82- //flickr.photos.getExif
83- //flickr.photos.getFavorites
76+ /**
77+ * Delete a photo from flickr.
78+ *
79+ * @link https://www.flickr.com/services/api/flickr.photos.delete.html
80+ * @param $photoId string The ID of the photo to delete.
81+ * @return bool
82+ */
83+ public function delete ($ photoId )
84+ {
85+ return (bool )$ this ->flickr ->request ('flickr.photos.delete ' , ['photo_id ' =>$ photoId ], true );
86+ }
87+
88+ /**
89+ * Returns all visible sets and pools the photo belongs to.
90+ *
91+ * @link https://www.flickr.com/services/api/flickr.photos.getAllContexts.html
92+ * @param $photoId string The photo to return information for.
93+ * @return bool
94+ */
95+ public function getAllContexts ($ photoId )
96+ {
97+ return $ this ->request ('flickr.photos.getAllContexts ' , ['photo_id ' =>$ photoId ]);
98+ }
99+
100+ /**
101+ * Fetch a list of recent photos from the calling users' contacts.
102+ *
103+ * @link https://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html
104+ * @param $count int|null Number of photos to return. Defaults to 10, maximum 50. This is only used if single_photo
105+ * is not passed.
106+ * @param $justFriends bool|null Set as 1 to only show photos from friends and family (excluding regular contacts).
107+ * @param $singlePhoto bool|null Only fetch one photo (the latest) per contact, instead of all photos in
108+ * chronological order.
109+ * @param $includeSelf bool|null Whether to include photos from the calling user.
110+ * @param $extras string|string[] An array or comma-delimited list of extra information to fetch for each returned
111+ * record. Currently supported fields include: license, date_upload, date_taken, owner_name, icon_server,
112+ * original_format, last_update. For more information see extras under flickr.photos.search.
113+ * @return mixed
114+ */
115+ public function getContactsPhotos (
116+ $ count = null ,
117+ $ justFriends = null ,
118+ $ singlePhoto = null ,
119+ $ includeSelf = null ,
120+ $ extras = null
121+ ) {
122+ if (is_array ($ extras )) {
123+ $ extras = join (', ' , $ extras );
124+ }
125+ $ params = [
126+ 'count ' => $ count ,
127+ 'just_friends ' => $ justFriends ,
128+ 'single_photo ' => $ singlePhoto ,
129+ 'include_self ' => $ includeSelf ,
130+ 'extras ' => $ extras
131+ ];
132+ $ response = $ this ->flickr ->request ('flickr.photos.getContactsPhotos ' , $ params );
133+ return isset ($ response ['photos ' ]['photo ' ]) ? $ response ['photos ' ]['photo ' ] : false ;
134+ }
135+
136+ /**
137+ * Fetch a list of recent public photos from a users' contacts.
138+ *
139+ * @link https://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html
140+ * @param $userId string The NSID of the user to fetch photos for.
141+ * @param $count int|null Number of photos to return. Defaults to 10, maximum 50. This is only used if $singlePhoto
142+ * is false.
143+ * @param $justFriends bool|null Whether to only show photos from friends and family (excluding regular contacts).
144+ * @param $singlePhoto bool|null Only fetch one photo (the latest) per contact, instead of all photos in
145+ * chronological order.
146+ * @param $includeSelf bool|null Whether to include photos from the user specified by $userId.
147+ * @param $extras string|string[]|null Array or comma-delimited list of extra information to fetch for each returned
148+ * record. Currently supported fields are: license, date_upload, date_taken, owner_name, icon_server,
149+ * original_format, last_update.
150+ * @return mixed
151+ */
152+ public function getContactsPublicPhotos (
153+ $ userId ,
154+ $ count = null ,
155+ $ justFriends = null ,
156+ $ singlePhoto = null ,
157+ $ includeSelf = null ,
158+ $ extras = null
159+ ) {
160+ if (is_array ($ extras )) {
161+ $ extras = join (', ' , $ extras );
162+ }
163+ $ params = [
164+ 'user_id ' => $ userId ,
165+ 'count ' => $ count ,
166+ 'just_friends ' => $ justFriends ,
167+ 'single_photo ' => $ singlePhoto ,
168+ 'include_self ' => $ includeSelf ,
169+ 'extras ' => $ extras
170+ ];
171+ $ response = $ this ->flickr ->request ('flickr.photos.getContactsPublicPhotos ' , $ params );
172+ return isset ($ response ['photos ' ]['photo ' ]) ? $ response ['photos ' ]['photo ' ] : false ;
173+ }
174+
175+ /**
176+ * Returns next and previous photos for a photo in a photostream.
177+ *
178+ * @link https://www.flickr.com/services/api/flickr.photos.getContext.html
179+ * @param $photoId string The ID of the photo to fetch the context for.
180+ * @return mixed
181+ */
182+ public function getContext ($ photoId )
183+ {
184+ return $ this ->flickr ->request ('flickr.photos.getContext ' , ['photo_id ' => $ photoId ]);
185+ }
186+
187+ /**
188+ * Gets a list of photo counts for the given date ranges for the calling user.
189+ *
190+ * @link https://www.flickr.com/services/api/flickr.photos.getCounts.html
191+ * @param $dates string|string[]|null Array or comma-delimited list of unix timestamps, denoting the periods to
192+ * return counts for. They should be specified smallest first.
193+ * @param $takenDates string|string[]|null Array or comma-delimited list of MySQL datetimes, denoting the periods to
194+ * return counts for. They should be specified smallest first.
195+ * @return bool
196+ */
197+ public function getCounts ($ dates = null , $ takenDates = null )
198+ {
199+ if (is_array ($ dates )) {
200+ $ dates = join (', ' , $ dates );
201+ }
202+ if (is_array ($ takenDates )) {
203+ $ takenDates = join (', ' , $ takenDates );
204+ }
205+ $ params = ['dates ' => $ dates , 'taken_dates ' => $ takenDates ];
206+ $ response = $ this ->flickr ->request ('flickr.photos.getCounts ' , $ params );
207+ return isset ($ response ['photocounts ' ]['photocount ' ]) ? $ response ['photocounts ' ]['photocount ' ] : false ;
208+ }
209+
210+ /**
211+ * Retrieve a list of EXIF/TIFF/GPS tags for a given photo. The calling user must have permission to view the photo.
212+ *
213+ * @link https://www.flickr.com/services/api/flickr.photos.getExif.html
214+ * @param $photoId string The ID of the photo to fetch information for.
215+ * @param $secret string|null The secret for the photo. If the correct secret is passed then permissions-checking is
216+ * skipped. This enables the 'sharing' of individual photos by passing around the ID and secret.
217+ * @return mixed
218+ */
219+ public function getExif ($ photoId , $ secret = null )
220+ {
221+ $ response = $ this ->flickr ->request ('flickr.photos.getExif ' , ['photo_id ' =>$ photoId , 'secret ' =>$ secret ]);
222+ return isset ($ response ['photo ' ]) ? $ response ['photo ' ] : false ;
223+ }
224+
225+ /**
226+ * Returns the list of people who have favorited a given photo.
227+ *
228+ * @link https://www.flickr.com/services/api/flickr.photos.getFavorites.html
229+ * @param $photoId string The ID of the photo to fetch the favoriters list for.
230+ * @param $page int|null The page of results to return. If this argument is omitted, it defaults to 1.
231+ * @param $perPage int|null Number of users to return per page. If this argument is omitted, it defaults to 10. The
232+ * maximum allowed value is 50.
233+ * @return mixed
234+ */
235+ public function getFavorites ($ photoId , $ page = null , $ perPage = null )
236+ {
237+ $ params = ['photo_id ' =>$ photoId , 'page ' =>$ page , 'per_page ' =>$ perPage ];
238+ $ response = $ this ->flickr ->request ('flickr.photos.getFavorites ' , $ params );
239+ return isset ($ response ['photo ' ]) ? $ response ['photo ' ] : false ;
240+ }
84241
85242 /**
86243 * Get information about a photo. The calling user must have permission to view the photo.
@@ -124,7 +281,7 @@ public function getSets($photoIds, $userId = null)
124281 if (!isset ($ sets ['photoset ' ])) {
125282 return false ;
126283 }
127-
284+
128285 // for users with more than 500 albums, we must search the photoId page by page (thanks, Flickr...)
129286 foreach (range (1 , $ sets ['pages ' ]) as $ pageNum ) {
130287 if ($ pageNum > 1 ) {
0 commit comments