1 | <?php |
---|
2 | /* phpFlickr |
---|
3 | * Written by Dan Coulter (dan@dancoulter.com) |
---|
4 | * Project Home Page: http://github.com/dancoulter/phpflickr |
---|
5 | * |
---|
6 | * This program is free software: you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation, either version 3 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | * |
---|
19 | */ |
---|
20 | if ( !class_exists('phpFlickr') ) { |
---|
21 | if (session_id() == "") { |
---|
22 | @session_start(); |
---|
23 | } |
---|
24 | |
---|
25 | class phpFlickr { |
---|
26 | var $api_key; |
---|
27 | var $secret; |
---|
28 | |
---|
29 | var $rest_endpoint = 'https://api.flickr.com/services/rest/'; |
---|
30 | var $upload_endpoint = 'https://up.flickr.com/services/upload/'; |
---|
31 | var $replace_endpoint = 'https://up.flickr.com/services/replace/'; |
---|
32 | var $req; |
---|
33 | var $response; |
---|
34 | var $parsed_response; |
---|
35 | var $cache = false; |
---|
36 | var $cache_db = null; |
---|
37 | var $cache_table = null; |
---|
38 | var $cache_dir = null; |
---|
39 | var $cache_expire = null; |
---|
40 | var $cache_key = null; |
---|
41 | var $last_request = null; |
---|
42 | var $die_on_error; |
---|
43 | var $error_code; |
---|
44 | Var $error_msg; |
---|
45 | var $token; |
---|
46 | var $php_version; |
---|
47 | var $custom_post = null, $custom_cache_get = null, $custom_cache_set = null; |
---|
48 | |
---|
49 | /* |
---|
50 | * When your database cache table hits this many rows, a cleanup |
---|
51 | * will occur to get rid of all of the old rows and cleanup the |
---|
52 | * garbage in the table. For most personal apps, 1000 rows should |
---|
53 | * be more than enough. If your site gets hit by a lot of traffic |
---|
54 | * or you have a lot of disk space to spare, bump this number up. |
---|
55 | * You should try to set it high enough that the cleanup only |
---|
56 | * happens every once in a while, so this will depend on the growth |
---|
57 | * of your table. |
---|
58 | */ |
---|
59 | var $max_cache_rows = 1000; |
---|
60 | |
---|
61 | function phpFlickr ($api_key, $secret = NULL, $die_on_error = false) { |
---|
62 | //The API Key must be set before any calls can be made. You can |
---|
63 | //get your own at https://www.flickr.com/services/api/misc.api_keys.html |
---|
64 | $this->api_key = $api_key; |
---|
65 | $this->secret = $secret; |
---|
66 | $this->die_on_error = $die_on_error; |
---|
67 | $this->service = "flickr"; |
---|
68 | |
---|
69 | //Find the PHP version and store it for future reference |
---|
70 | $this->php_version = explode("-", phpversion()); |
---|
71 | $this->php_version = explode(".", $this->php_version[0]); |
---|
72 | } |
---|
73 | |
---|
74 | function enableCache ($type, $connection, $cache_expire = 600, $table = 'flickr_cache') { |
---|
75 | // Turns on caching. $type must be either "db" (for database caching) or "fs" (for filesystem). |
---|
76 | // When using db, $connection must be a PEAR::DB connection string. Example: |
---|
77 | // "mysql://user:password@server/database" |
---|
78 | // If the $table, doesn't exist, it will attempt to create it. |
---|
79 | // When using file system, caching, the $connection is the folder that the web server has write |
---|
80 | // access to. Use absolute paths for best results. Relative paths may have unexpected behavior |
---|
81 | // when you include this. They'll usually work, you'll just want to test them. |
---|
82 | if ($type == 'db') { |
---|
83 | if ( preg_match('|mysql://([^:]*):([^@]*)@([^/]*)/(.*)|', $connection, $matches) ) { |
---|
84 | //Array ( [0] => mysql://user:password@server/database [1] => user [2] => password [3] => server [4] => database ) |
---|
85 | $db = mysqli_connect($matches[3], $matches[1], $matches[2]); |
---|
86 | mysqli_query($db, "USE $matches[4]"); |
---|
87 | |
---|
88 | /* |
---|
89 | * If high performance is crucial, you can easily comment |
---|
90 | * out this query once you've created your database table. |
---|
91 | */ |
---|
92 | mysqli_query($db, " |
---|
93 | CREATE TABLE IF NOT EXISTS `$table` ( |
---|
94 | `request` CHAR( 35 ) NOT NULL , |
---|
95 | `response` MEDIUMTEXT NOT NULL , |
---|
96 | `expiration` DATETIME NOT NULL , |
---|
97 | INDEX ( `request` ) |
---|
98 | ) |
---|
99 | "); |
---|
100 | |
---|
101 | $result = mysqli_query($db, "SELECT COUNT(*) FROM $table"); |
---|
102 | $result = mysqli_fetch_row($result); |
---|
103 | if ( $result[0] > $this->max_cache_rows ) { |
---|
104 | mysqli_query($db, "DELETE FROM $table WHERE expiration < DATE_SUB(NOW(), INTERVAL $cache_expire second)"); |
---|
105 | mysqli_query($db, 'OPTIMIZE TABLE ' . $this->cache_table); |
---|
106 | } |
---|
107 | $this->cache = 'db'; |
---|
108 | $this->cache_db = $db; |
---|
109 | $this->cache_table = $table; |
---|
110 | } |
---|
111 | } elseif ($type == 'fs') { |
---|
112 | $this->cache = 'fs'; |
---|
113 | $connection = realpath($connection); |
---|
114 | $this->cache_dir = $connection; |
---|
115 | if ($dir = opendir($this->cache_dir)) { |
---|
116 | while ($file = readdir($dir)) { |
---|
117 | if (substr($file, -6) == '.cache' && ((filemtime($this->cache_dir . '/' . $file) + $cache_expire) < time()) ) { |
---|
118 | unlink($this->cache_dir . '/' . $file); |
---|
119 | } |
---|
120 | } |
---|
121 | } |
---|
122 | } elseif ( $type == 'custom' ) { |
---|
123 | $this->cache = "custom"; |
---|
124 | $this->custom_cache_get = $connection[0]; |
---|
125 | $this->custom_cache_set = $connection[1]; |
---|
126 | } |
---|
127 | $this->cache_expire = $cache_expire; |
---|
128 | } |
---|
129 | |
---|
130 | function getCached ($request) |
---|
131 | { |
---|
132 | //Checks the database or filesystem for a cached result to the request. |
---|
133 | //If there is no cache result, it returns a value of false. If it finds one, |
---|
134 | //it returns the unparsed XML. |
---|
135 | foreach ( $request as $key => $value ) { |
---|
136 | if ( empty($value) ) unset($request[$key]); |
---|
137 | else $request[$key] = (string) $request[$key]; |
---|
138 | } |
---|
139 | //if ( is_user_logged_in() ) print_r($request); |
---|
140 | $reqhash = md5(serialize($request)); |
---|
141 | $this->cache_key = $reqhash; |
---|
142 | $this->cache_request = $request; |
---|
143 | if ($this->cache == 'db') { |
---|
144 | $result = mysqli_query($this->cache_db, "SELECT response FROM " . $this->cache_table . " WHERE request = '" . $reqhash . "' AND DATE_SUB(NOW(), INTERVAL " . (int) $this->cache_expire . " SECOND) < expiration"); |
---|
145 | if ( mysqli_num_rows($result) ) { |
---|
146 | $result = mysqli_fetch_assoc($result); |
---|
147 | return $result['response']; |
---|
148 | } else { |
---|
149 | return false; |
---|
150 | } |
---|
151 | } elseif ($this->cache == 'fs') { |
---|
152 | $file = $this->cache_dir . '/' . $reqhash . '.cache'; |
---|
153 | if (file_exists($file)) { |
---|
154 | if ($this->php_version[0] > 4 || ($this->php_version[0] == 4 && $this->php_version[1] >= 3)) { |
---|
155 | return file_get_contents($file); |
---|
156 | } else { |
---|
157 | return implode('', file($file)); |
---|
158 | } |
---|
159 | } |
---|
160 | } elseif ( $this->cache == 'custom' ) { |
---|
161 | return call_user_func_array($this->custom_cache_get, array($reqhash)); |
---|
162 | } |
---|
163 | return false; |
---|
164 | } |
---|
165 | |
---|
166 | function cache ($request, $response) |
---|
167 | { |
---|
168 | //Caches the unparsed response of a request. |
---|
169 | unset($request['api_sig']); |
---|
170 | foreach ( $request as $key => $value ) { |
---|
171 | if ( empty($value) ) unset($request[$key]); |
---|
172 | else $request[$key] = (string) $request[$key]; |
---|
173 | } |
---|
174 | $reqhash = md5(serialize($request)); |
---|
175 | if ($this->cache == 'db') { |
---|
176 | //$this->cache_db->query("DELETE FROM $this->cache_table WHERE request = '$reqhash'"); |
---|
177 | $result = mysqli_query($this->cache_db, "SELECT COUNT(*) FROM " . $this->cache_table . " WHERE request = '" . $reqhash . "'"); |
---|
178 | $result = mysqli_fetch_row($result); |
---|
179 | if ( $result[0] ) { |
---|
180 | $sql = "UPDATE " . $this->cache_table . " SET response = '" . str_replace("'", "''", $response) . "', expiration = '" . strftime("%Y-%m-%d %H:%M:%S") . "' WHERE request = '" . $reqhash . "'"; |
---|
181 | mysqli_query($this->cache_db, $sql); |
---|
182 | } else { |
---|
183 | $sql = "INSERT INTO " . $this->cache_table . " (request, response, expiration) VALUES ('$reqhash', '" . str_replace("'", "''", $response) . "', '" . strftime("%Y-%m-%d %H:%M:%S") . "')"; |
---|
184 | mysqli_query($this->cache_db, $sql); |
---|
185 | } |
---|
186 | } elseif ($this->cache == "fs") { |
---|
187 | $file = $this->cache_dir . "/" . $reqhash . ".cache"; |
---|
188 | $fstream = fopen($file, "w"); |
---|
189 | $result = fwrite($fstream,$response); |
---|
190 | fclose($fstream); |
---|
191 | return $result; |
---|
192 | } elseif ( $this->cache == "custom" ) { |
---|
193 | return call_user_func_array($this->custom_cache_set, array($reqhash, $response, $this->cache_expire)); |
---|
194 | } |
---|
195 | return false; |
---|
196 | } |
---|
197 | |
---|
198 | function setCustomPost ( $function ) { |
---|
199 | $this->custom_post = $function; |
---|
200 | } |
---|
201 | |
---|
202 | function post ($data, $type = null) { |
---|
203 | if ( is_null($type) ) { |
---|
204 | $url = $this->rest_endpoint; |
---|
205 | } |
---|
206 | |
---|
207 | if ( !is_null($this->custom_post) ) { |
---|
208 | return call_user_func($this->custom_post, $url, $data); |
---|
209 | } |
---|
210 | |
---|
211 | if ( !preg_match("|https://(.*?)(/.*)|", $url, $matches) ) { |
---|
212 | die('There was some problem figuring out your endpoint'); |
---|
213 | } |
---|
214 | |
---|
215 | if ( function_exists('curl_init') ) { |
---|
216 | // Has curl. Use it! |
---|
217 | $curl = curl_init($this->rest_endpoint); |
---|
218 | curl_setopt($curl, CURLOPT_POST, true); |
---|
219 | curl_setopt($curl, CURLOPT_POSTFIELDS, $data); |
---|
220 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
---|
221 | $response = curl_exec($curl); |
---|
222 | curl_close($curl); |
---|
223 | } else { |
---|
224 | // Use sockets. |
---|
225 | foreach ( $data as $key => $value ) { |
---|
226 | $data[$key] = $key . '=' . urlencode($value); |
---|
227 | } |
---|
228 | $data = implode('&', $data); |
---|
229 | |
---|
230 | $fp = @pfsockopen($matches[1], 80); |
---|
231 | if (!$fp) { |
---|
232 | die('Could not connect to the web service'); |
---|
233 | } |
---|
234 | fputs ($fp,'POST ' . $matches[2] . " HTTP/1.1\n"); |
---|
235 | fputs ($fp,'Host: ' . $matches[1] . "\n"); |
---|
236 | fputs ($fp,"Content-type: application/x-www-form-urlencoded\n"); |
---|
237 | fputs ($fp,"Content-length: ".strlen($data)."\n"); |
---|
238 | fputs ($fp,"Connection: close\r\n\r\n"); |
---|
239 | fputs ($fp,$data . "\n\n"); |
---|
240 | $response = ""; |
---|
241 | while(!feof($fp)) { |
---|
242 | $response .= fgets($fp, 1024); |
---|
243 | } |
---|
244 | fclose ($fp); |
---|
245 | $chunked = false; |
---|
246 | $http_status = trim(substr($response, 0, strpos($response, "\n"))); |
---|
247 | if ( $http_status != 'HTTP/1.1 200 OK' ) { |
---|
248 | die('The web service endpoint returned a "' . $http_status . '" response'); |
---|
249 | } |
---|
250 | if ( strpos($response, 'Transfer-Encoding: chunked') !== false ) { |
---|
251 | $temp = trim(strstr($response, "\r\n\r\n")); |
---|
252 | $response = ''; |
---|
253 | $length = trim(substr($temp, 0, strpos($temp, "\r"))); |
---|
254 | while ( trim($temp) != "0" && ($length = trim(substr($temp, 0, strpos($temp, "\r")))) != "0" ) { |
---|
255 | $response .= trim(substr($temp, strlen($length)+2, hexdec($length))); |
---|
256 | $temp = trim(substr($temp, strlen($length) + 2 + hexdec($length))); |
---|
257 | } |
---|
258 | } elseif ( strpos($response, 'HTTP/1.1 200 OK') !== false ) { |
---|
259 | $response = trim(strstr($response, "\r\n\r\n")); |
---|
260 | } |
---|
261 | } |
---|
262 | return $response; |
---|
263 | } |
---|
264 | |
---|
265 | function request ($command, $args = array(), $nocache = false) |
---|
266 | { |
---|
267 | //Sends a request to Flickr's REST endpoint via POST. |
---|
268 | if (substr($command,0,7) != "flickr.") { |
---|
269 | $command = "flickr." . $command; |
---|
270 | } |
---|
271 | |
---|
272 | //Process arguments, including method and login data. |
---|
273 | $args = array_merge(array("method" => $command, "format" => "php_serial", "api_key" => $this->api_key), $args); |
---|
274 | if (!empty($this->token)) { |
---|
275 | $args = array_merge($args, array("auth_token" => $this->token)); |
---|
276 | } elseif (!empty($_SESSION['phpFlickr_auth_token'])) { |
---|
277 | $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token'])); |
---|
278 | } |
---|
279 | ksort($args); |
---|
280 | $auth_sig = ""; |
---|
281 | $this->last_request = $args; |
---|
282 | if (!($this->response = $this->getCached($args)) || $nocache) { |
---|
283 | foreach ($args as $key => $data) { |
---|
284 | if ( is_null($data) ) { |
---|
285 | unset($args[$key]); |
---|
286 | continue; |
---|
287 | } |
---|
288 | $auth_sig .= $key . $data; |
---|
289 | } |
---|
290 | if (!empty($this->secret)) { |
---|
291 | $api_sig = md5($this->secret . $auth_sig); |
---|
292 | $args['api_sig'] = $api_sig; |
---|
293 | } |
---|
294 | $this->response = $this->post($args); |
---|
295 | $this->cache($args, $this->response); |
---|
296 | } |
---|
297 | |
---|
298 | /* |
---|
299 | * Uncomment this line (and comment out the next one) if you're doing large queries |
---|
300 | * and you're concerned about time. This will, however, change the structure of |
---|
301 | * the result, so be sure that you look at the results. |
---|
302 | */ |
---|
303 | //$this->parsed_response = unserialize($this->response); |
---|
304 | $this->parsed_response = $this->clean_text_nodes(unserialize($this->response)); |
---|
305 | if ($this->parsed_response['stat'] == 'fail') { |
---|
306 | if ($this->die_on_error) die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}"); |
---|
307 | else { |
---|
308 | $this->error_code = $this->parsed_response['code']; |
---|
309 | $this->error_msg = $this->parsed_response['message']; |
---|
310 | $this->parsed_response = false; |
---|
311 | } |
---|
312 | } else { |
---|
313 | $this->error_code = false; |
---|
314 | $this->error_msg = false; |
---|
315 | } |
---|
316 | return $this->response; |
---|
317 | } |
---|
318 | |
---|
319 | function clean_text_nodes ($arr) { |
---|
320 | if (!is_array($arr)) { |
---|
321 | return $arr; |
---|
322 | } elseif (count($arr) == 0) { |
---|
323 | return $arr; |
---|
324 | } elseif (count($arr) == 1 && array_key_exists('_content', $arr)) { |
---|
325 | return $arr['_content']; |
---|
326 | } else { |
---|
327 | foreach ($arr as $key => $element) { |
---|
328 | $arr[$key] = $this->clean_text_nodes($element); |
---|
329 | } |
---|
330 | return($arr); |
---|
331 | } |
---|
332 | } |
---|
333 | |
---|
334 | function setToken ($token) { |
---|
335 | // Sets an authentication token to use instead of the session variable |
---|
336 | $this->token = $token; |
---|
337 | } |
---|
338 | |
---|
339 | function setProxy ($server, $port) { |
---|
340 | // Sets the proxy for all phpFlickr calls. |
---|
341 | $this->req->setProxy($server, $port); |
---|
342 | } |
---|
343 | |
---|
344 | function getErrorCode () { |
---|
345 | // Returns the error code of the last call. If the last call did not |
---|
346 | // return an error. This will return a false boolean. |
---|
347 | return $this->error_code; |
---|
348 | } |
---|
349 | |
---|
350 | function getErrorMsg () { |
---|
351 | // Returns the error message of the last call. If the last call did not |
---|
352 | // return an error. This will return a false boolean. |
---|
353 | return $this->error_msg; |
---|
354 | } |
---|
355 | |
---|
356 | /* These functions are front ends for the flickr calls */ |
---|
357 | function get_biggest_size($image_id, $limit='original') |
---|
358 | { |
---|
359 | $sizes = array( |
---|
360 | "square" => "Square", |
---|
361 | "square_75" => "Square", |
---|
362 | "square_150" => "Large Square", |
---|
363 | "thumbnail" => "Thumbnail", |
---|
364 | "small" => "Small", |
---|
365 | "small_240" => "Small", |
---|
366 | "small_320" => "Small 320", |
---|
367 | "medium" => "Medium", |
---|
368 | "medium_500" => "Medium", |
---|
369 | "medium_640" => "Medium 640", |
---|
370 | "medium_800" => "Medium 800", |
---|
371 | "large" => "Large", |
---|
372 | "large_1024" => "Large", |
---|
373 | "large_1600" => "Large 1600", |
---|
374 | "large_2048" => "Large 2048", |
---|
375 | "original" => "Original", |
---|
376 | ); |
---|
377 | |
---|
378 | if (!array_key_exists($limit, $sizes)) $limit = 'medium'; |
---|
379 | $limit = array_search($limit, array_keys($sizes)); |
---|
380 | |
---|
381 | $img_sizes = $this->photos_getSizes($image_id); |
---|
382 | $img_sizes = array_reverse($img_sizes); |
---|
383 | |
---|
384 | foreach ($img_sizes as $size) |
---|
385 | { |
---|
386 | if ($limit >= array_search($size['label'], array_values($sizes))) |
---|
387 | { |
---|
388 | return $size['source']; |
---|
389 | } |
---|
390 | } |
---|
391 | |
---|
392 | return null; |
---|
393 | } |
---|
394 | |
---|
395 | function buildPhotoURL ($photo, $size = "Medium") { |
---|
396 | //receives an array (can use the individual photo data returned |
---|
397 | //from an API call) and returns a URL (doesn't mean that the |
---|
398 | //file size exists) |
---|
399 | $sizes = array( |
---|
400 | "square" => "_s", |
---|
401 | "square_75" => "_s", |
---|
402 | "square_150" => "_q", |
---|
403 | "thumbnail" => "_t", |
---|
404 | "small" => "_m", |
---|
405 | "small_240" => "_m", |
---|
406 | "small_320" => "_n", |
---|
407 | "medium" => "", |
---|
408 | "medium_500" => "", |
---|
409 | "medium_640" => "_z", |
---|
410 | "medium_800" => "_c", |
---|
411 | "large" => "_b", |
---|
412 | "large_1024" => "_b", |
---|
413 | "large_1600" => "_h", |
---|
414 | "large_2048" => "_k", |
---|
415 | "original" => "_o", |
---|
416 | ); |
---|
417 | |
---|
418 | $size = strtolower($size); |
---|
419 | if (!array_key_exists($size, $sizes)) { |
---|
420 | $size = "medium"; |
---|
421 | } |
---|
422 | |
---|
423 | if ($size == "original") { |
---|
424 | $url = "https://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['originalsecret'] . "_o" . "." . $photo['originalformat']; |
---|
425 | } else { |
---|
426 | $url = "https://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes[$size] . ".jpg"; |
---|
427 | } |
---|
428 | return $url; |
---|
429 | } |
---|
430 | |
---|
431 | function sync_upload ($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) { |
---|
432 | if ( function_exists('curl_init') ) { |
---|
433 | // Has curl. Use it! |
---|
434 | |
---|
435 | //Process arguments, including method and login data. |
---|
436 | $args = array("api_key" => $this->api_key, "title" => $title, "description" => $description, "tags" => $tags, "is_public" => $is_public, "is_friend" => $is_friend, "is_family" => $is_family); |
---|
437 | if (!empty($this->token)) { |
---|
438 | $args = array_merge($args, array("auth_token" => $this->token)); |
---|
439 | } elseif (!empty($_SESSION['phpFlickr_auth_token'])) { |
---|
440 | $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token'])); |
---|
441 | } |
---|
442 | |
---|
443 | ksort($args); |
---|
444 | $auth_sig = ""; |
---|
445 | foreach ($args as $key => $data) { |
---|
446 | if ( is_null($data) ) { |
---|
447 | unset($args[$key]); |
---|
448 | } else { |
---|
449 | $auth_sig .= $key . $data; |
---|
450 | } |
---|
451 | } |
---|
452 | if (!empty($this->secret)) { |
---|
453 | $api_sig = md5($this->secret . $auth_sig); |
---|
454 | $args["api_sig"] = $api_sig; |
---|
455 | } |
---|
456 | |
---|
457 | $photo = realpath($photo); |
---|
458 | $args['photo'] = '@' . $photo; |
---|
459 | |
---|
460 | |
---|
461 | $curl = curl_init($this->upload_endpoint); |
---|
462 | curl_setopt($curl, CURLOPT_POST, true); |
---|
463 | curl_setopt($curl, CURLOPT_POSTFIELDS, $args); |
---|
464 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
---|
465 | $response = curl_exec($curl); |
---|
466 | $this->response = $response; |
---|
467 | curl_close($curl); |
---|
468 | |
---|
469 | $rsp = explode("\n", $response); |
---|
470 | foreach ($rsp as $line) { |
---|
471 | if (preg_match('|<err code="([0-9]+)" msg="(.*)"|', $line, $match)) { |
---|
472 | if ($this->die_on_error) |
---|
473 | die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}"); |
---|
474 | else { |
---|
475 | $this->error_code = $match[1]; |
---|
476 | $this->error_msg = $match[2]; |
---|
477 | $this->parsed_response = false; |
---|
478 | return false; |
---|
479 | } |
---|
480 | } elseif (preg_match("|<photoid>(.*)</photoid>|", $line, $match)) { |
---|
481 | $this->error_code = false; |
---|
482 | $this->error_msg = false; |
---|
483 | return $match[1]; |
---|
484 | } |
---|
485 | } |
---|
486 | |
---|
487 | } else { |
---|
488 | die("Sorry, your server must support CURL in order to upload files"); |
---|
489 | } |
---|
490 | |
---|
491 | } |
---|
492 | |
---|
493 | function async_upload ($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) { |
---|
494 | if ( function_exists('curl_init') ) { |
---|
495 | // Has curl. Use it! |
---|
496 | |
---|
497 | //Process arguments, including method and login data. |
---|
498 | $args = array("async" => 1, "api_key" => $this->api_key, "title" => $title, "description" => $description, "tags" => $tags, "is_public" => $is_public, "is_friend" => $is_friend, "is_family" => $is_family); |
---|
499 | if (!empty($this->token)) { |
---|
500 | $args = array_merge($args, array("auth_token" => $this->token)); |
---|
501 | } elseif (!empty($_SESSION['phpFlickr_auth_token'])) { |
---|
502 | $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token'])); |
---|
503 | } |
---|
504 | |
---|
505 | ksort($args); |
---|
506 | $auth_sig = ""; |
---|
507 | foreach ($args as $key => $data) { |
---|
508 | if ( is_null($data) ) { |
---|
509 | unset($args[$key]); |
---|
510 | } else { |
---|
511 | $auth_sig .= $key . $data; |
---|
512 | } |
---|
513 | } |
---|
514 | if (!empty($this->secret)) { |
---|
515 | $api_sig = md5($this->secret . $auth_sig); |
---|
516 | $args["api_sig"] = $api_sig; |
---|
517 | } |
---|
518 | |
---|
519 | $photo = realpath($photo); |
---|
520 | $args['photo'] = '@' . $photo; |
---|
521 | |
---|
522 | |
---|
523 | $curl = curl_init($this->upload_endpoint); |
---|
524 | curl_setopt($curl, CURLOPT_POST, true); |
---|
525 | curl_setopt($curl, CURLOPT_POSTFIELDS, $args); |
---|
526 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
---|
527 | $response = curl_exec($curl); |
---|
528 | $this->response = $response; |
---|
529 | curl_close($curl); |
---|
530 | |
---|
531 | $rsp = explode("\n", $response); |
---|
532 | foreach ($rsp as $line) { |
---|
533 | if (preg_match('/<err code="([0-9]+)" msg="(.*)"/', $line, $match)) { |
---|
534 | if ($this->die_on_error) |
---|
535 | die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}"); |
---|
536 | else { |
---|
537 | $this->error_code = $match[1]; |
---|
538 | $this->error_msg = $match[2]; |
---|
539 | $this->parsed_response = false; |
---|
540 | return false; |
---|
541 | } |
---|
542 | } elseif (preg_match("/<ticketid>(.*)</", $line, $match)) { |
---|
543 | $this->error_code = false; |
---|
544 | $this->error_msg = false; |
---|
545 | return $match[1]; |
---|
546 | } |
---|
547 | } |
---|
548 | } else { |
---|
549 | die("Sorry, your server must support CURL in order to upload files"); |
---|
550 | } |
---|
551 | } |
---|
552 | |
---|
553 | // Interface for new replace API method. |
---|
554 | function replace ($photo, $photo_id, $async = null) { |
---|
555 | if ( function_exists('curl_init') ) { |
---|
556 | // Has curl. Use it! |
---|
557 | |
---|
558 | //Process arguments, including method and login data. |
---|
559 | $args = array("api_key" => $this->api_key, "photo_id" => $photo_id, "async" => $async); |
---|
560 | if (!empty($this->token)) { |
---|
561 | $args = array_merge($args, array("auth_token" => $this->token)); |
---|
562 | } elseif (!empty($_SESSION['phpFlickr_auth_token'])) { |
---|
563 | $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token'])); |
---|
564 | } |
---|
565 | |
---|
566 | ksort($args); |
---|
567 | $auth_sig = ""; |
---|
568 | foreach ($args as $key => $data) { |
---|
569 | if ( is_null($data) ) { |
---|
570 | unset($args[$key]); |
---|
571 | } else { |
---|
572 | $auth_sig .= $key . $data; |
---|
573 | } |
---|
574 | } |
---|
575 | if (!empty($this->secret)) { |
---|
576 | $api_sig = md5($this->secret . $auth_sig); |
---|
577 | $args["api_sig"] = $api_sig; |
---|
578 | } |
---|
579 | |
---|
580 | $photo = realpath($photo); |
---|
581 | $args['photo'] = '@' . $photo; |
---|
582 | |
---|
583 | |
---|
584 | $curl = curl_init($this->replace_endpoint); |
---|
585 | curl_setopt($curl, CURLOPT_POST, true); |
---|
586 | curl_setopt($curl, CURLOPT_POSTFIELDS, $args); |
---|
587 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
---|
588 | $response = curl_exec($curl); |
---|
589 | $this->response = $response; |
---|
590 | curl_close($curl); |
---|
591 | |
---|
592 | if ($async == 1) |
---|
593 | $find = 'ticketid'; |
---|
594 | else |
---|
595 | $find = 'photoid'; |
---|
596 | |
---|
597 | $rsp = explode("\n", $response); |
---|
598 | foreach ($rsp as $line) { |
---|
599 | if (preg_match('|<err code="([0-9]+)" msg="(.*)"|', $line, $match)) { |
---|
600 | if ($this->die_on_error) |
---|
601 | die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}"); |
---|
602 | else { |
---|
603 | $this->error_code = $match[1]; |
---|
604 | $this->error_msg = $match[2]; |
---|
605 | $this->parsed_response = false; |
---|
606 | return false; |
---|
607 | } |
---|
608 | } elseif (preg_match("|<" . $find . ">(.*)</|", $line, $match)) { |
---|
609 | $this->error_code = false; |
---|
610 | $this->error_msg = false; |
---|
611 | return $match[1]; |
---|
612 | } |
---|
613 | } |
---|
614 | } else { |
---|
615 | die("Sorry, your server must support CURL in order to upload files"); |
---|
616 | } |
---|
617 | } |
---|
618 | |
---|
619 | function auth ($perms = "read", $remember_uri = true) { |
---|
620 | // Redirects to Flickr's authentication piece if there is no valid token. |
---|
621 | // If remember_uri is set to false, the callback script (included) will |
---|
622 | // redirect to its default page. |
---|
623 | |
---|
624 | if (empty($_SESSION['phpFlickr_auth_token']) && empty($this->token)) { |
---|
625 | if ( $remember_uri === true ) { |
---|
626 | $_SESSION['phpFlickr_auth_redirect'] = $_SERVER['REQUEST_URI']; |
---|
627 | } elseif ( $remember_uri !== false ) { |
---|
628 | $_SESSION['phpFlickr_auth_redirect'] = $remember_uri; |
---|
629 | } |
---|
630 | $api_sig = md5($this->secret . "api_key" . $this->api_key . "perms" . $perms); |
---|
631 | |
---|
632 | if ($this->service == "23") { |
---|
633 | header("Location: http://www.23hq.com/services/auth/?api_key=" . $this->api_key . "&perms=" . $perms . "&api_sig=". $api_sig); |
---|
634 | } else { |
---|
635 | header("Location: https://www.flickr.com/services/auth/?api_key=" . $this->api_key . "&perms=" . $perms . "&api_sig=". $api_sig); |
---|
636 | } |
---|
637 | exit; |
---|
638 | } else { |
---|
639 | $tmp = $this->die_on_error; |
---|
640 | $this->die_on_error = false; |
---|
641 | $rsp = $this->auth_checkToken(); |
---|
642 | if ($this->error_code !== false) { |
---|
643 | unset($_SESSION['phpFlickr_auth_token']); |
---|
644 | $this->auth($perms, $remember_uri); |
---|
645 | } |
---|
646 | $this->die_on_error = $tmp; |
---|
647 | return $rsp['perms']; |
---|
648 | } |
---|
649 | } |
---|
650 | |
---|
651 | function auth_url($frob, $perms = 'read') { |
---|
652 | $sig = md5(sprintf('%sapi_key%sfrob%sperms%s', $this->secret, $this->api_key, $frob, $perms)); |
---|
653 | return sprintf('https://flickr.com/services/auth/?api_key=%s&perms=%s&frob=%s&api_sig=%s', $this->api_key, $perms, $frob, $sig); |
---|
654 | } |
---|
655 | |
---|
656 | /******************************* |
---|
657 | |
---|
658 | To use the phpFlickr::call method, pass a string containing the API method you want |
---|
659 | to use and an associative array of arguments. For example: |
---|
660 | $result = $f->call("flickr.photos.comments.getList", array("photo_id"=>'34952612')); |
---|
661 | This method will allow you to make calls to arbitrary methods that haven't been |
---|
662 | implemented in phpFlickr yet. |
---|
663 | |
---|
664 | *******************************/ |
---|
665 | |
---|
666 | function call ($method, $arguments) { |
---|
667 | foreach ( $arguments as $key => $value ) { |
---|
668 | if ( is_null($value) ) unset($arguments[$key]); |
---|
669 | } |
---|
670 | $this->request($method, $arguments); |
---|
671 | return $this->parsed_response ? $this->parsed_response : false; |
---|
672 | } |
---|
673 | |
---|
674 | /* |
---|
675 | These functions are the direct implementations of flickr calls. |
---|
676 | For method documentation, including arguments, visit the address |
---|
677 | included in a comment in the function. |
---|
678 | */ |
---|
679 | |
---|
680 | /* Activity methods */ |
---|
681 | function activity_userComments ($per_page = NULL, $page = NULL) { |
---|
682 | /* https://www.flickr.com/services/api/flickr.activity.userComments.html */ |
---|
683 | $this->request('flickr.activity.userComments', array("per_page" => $per_page, "page" => $page)); |
---|
684 | return $this->parsed_response ? $this->parsed_response['items']['item'] : false; |
---|
685 | } |
---|
686 | |
---|
687 | function activity_userPhotos ($timeframe = NULL, $per_page = NULL, $page = NULL) { |
---|
688 | /* https://www.flickr.com/services/api/flickr.activity.userPhotos.html */ |
---|
689 | $this->request('flickr.activity.userPhotos', array("timeframe" => $timeframe, "per_page" => $per_page, "page" => $page)); |
---|
690 | return $this->parsed_response ? $this->parsed_response['items']['item'] : false; |
---|
691 | } |
---|
692 | |
---|
693 | /* Authentication methods */ |
---|
694 | function auth_checkToken () { |
---|
695 | /* https://www.flickr.com/services/api/flickr.auth.checkToken.html */ |
---|
696 | $this->request('flickr.auth.checkToken'); |
---|
697 | return $this->parsed_response ? $this->parsed_response['auth'] : false; |
---|
698 | } |
---|
699 | |
---|
700 | function auth_getFrob () { |
---|
701 | /* https://www.flickr.com/services/api/flickr.auth.getFrob.html */ |
---|
702 | $this->request('flickr.auth.getFrob'); |
---|
703 | return $this->parsed_response ? $this->parsed_response['frob'] : false; |
---|
704 | } |
---|
705 | |
---|
706 | function auth_getFullToken ($mini_token) { |
---|
707 | /* https://www.flickr.com/services/api/flickr.auth.getFullToken.html */ |
---|
708 | $this->request('flickr.auth.getFullToken', array('mini_token'=>$mini_token)); |
---|
709 | return $this->parsed_response ? $this->parsed_response['auth'] : false; |
---|
710 | } |
---|
711 | |
---|
712 | function auth_getToken ($frob) { |
---|
713 | /* https://www.flickr.com/services/api/flickr.auth.getToken.html */ |
---|
714 | $this->request('flickr.auth.getToken', array('frob'=>$frob)); |
---|
715 | $_SESSION['phpFlickr_auth_token'] = $this->parsed_response['auth']['token']; |
---|
716 | return $this->parsed_response ? $this->parsed_response['auth'] : false; |
---|
717 | } |
---|
718 | |
---|
719 | /* Blogs methods */ |
---|
720 | function blogs_getList ($service = NULL) { |
---|
721 | /* https://www.flickr.com/services/api/flickr.blogs.getList.html */ |
---|
722 | $rsp = $this->call('flickr.blogs.getList', array('service' => $service)); |
---|
723 | return $rsp['blogs']['blog']; |
---|
724 | } |
---|
725 | |
---|
726 | function blogs_getServices () { |
---|
727 | /* https://www.flickr.com/services/api/flickr.blogs.getServices.html */ |
---|
728 | return $this->call('flickr.blogs.getServices', array()); |
---|
729 | } |
---|
730 | |
---|
731 | function blogs_postPhoto ($blog_id = NULL, $photo_id, $title, $description, $blog_password = NULL, $service = NULL) { |
---|
732 | /* https://www.flickr.com/services/api/flickr.blogs.postPhoto.html */ |
---|
733 | return $this->call('flickr.blogs.postPhoto', array('blog_id' => $blog_id, 'photo_id' => $photo_id, 'title' => $title, 'description' => $description, 'blog_password' => $blog_password, 'service' => $service)); |
---|
734 | } |
---|
735 | |
---|
736 | /* Collections Methods */ |
---|
737 | function collections_getInfo ($collection_id) { |
---|
738 | /* https://www.flickr.com/services/api/flickr.collections.getInfo.html */ |
---|
739 | return $this->call('flickr.collections.getInfo', array('collection_id' => $collection_id)); |
---|
740 | } |
---|
741 | |
---|
742 | function collections_getTree ($collection_id = NULL, $user_id = NULL) { |
---|
743 | /* https://www.flickr.com/services/api/flickr.collections.getTree.html */ |
---|
744 | return $this->call('flickr.collections.getTree', array('collection_id' => $collection_id, 'user_id' => $user_id)); |
---|
745 | } |
---|
746 | |
---|
747 | /* Commons Methods */ |
---|
748 | function commons_getInstitutions () { |
---|
749 | /* https://www.flickr.com/services/api/flickr.commons.getInstitutions.html */ |
---|
750 | return $this->call('flickr.commons.getInstitutions', array()); |
---|
751 | } |
---|
752 | |
---|
753 | /* Contacts Methods */ |
---|
754 | function contacts_getList ($filter = NULL, $page = NULL, $per_page = NULL) { |
---|
755 | /* https://www.flickr.com/services/api/flickr.contacts.getList.html */ |
---|
756 | $this->request('flickr.contacts.getList', array('filter'=>$filter, 'page'=>$page, 'per_page'=>$per_page)); |
---|
757 | return $this->parsed_response ? $this->parsed_response['contacts'] : false; |
---|
758 | } |
---|
759 | |
---|
760 | function contacts_getPublicList ($user_id, $page = NULL, $per_page = NULL) { |
---|
761 | /* https://www.flickr.com/services/api/flickr.contacts.getPublicList.html */ |
---|
762 | $this->request('flickr.contacts.getPublicList', array('user_id'=>$user_id, 'page'=>$page, 'per_page'=>$per_page)); |
---|
763 | return $this->parsed_response ? $this->parsed_response['contacts'] : false; |
---|
764 | } |
---|
765 | |
---|
766 | function contacts_getListRecentlyUploaded ($date_lastupload = NULL, $filter = NULL) { |
---|
767 | /* https://www.flickr.com/services/api/flickr.contacts.getListRecentlyUploaded.html */ |
---|
768 | return $this->call('flickr.contacts.getListRecentlyUploaded', array('date_lastupload' => $date_lastupload, 'filter' => $filter)); |
---|
769 | } |
---|
770 | |
---|
771 | /* Favorites Methods */ |
---|
772 | function favorites_add ($photo_id) { |
---|
773 | /* https://www.flickr.com/services/api/flickr.favorites.add.html */ |
---|
774 | $this->request('flickr.favorites.add', array('photo_id'=>$photo_id), TRUE); |
---|
775 | return $this->parsed_response ? true : false; |
---|
776 | } |
---|
777 | |
---|
778 | function favorites_getList ($user_id = NULL, $jump_to = NULL, $min_fave_date = NULL, $max_fave_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
779 | /* https://www.flickr.com/services/api/flickr.favorites.getList.html */ |
---|
780 | return $this->call('flickr.favorites.getList', array('user_id' => $user_id, 'jump_to' => $jump_to, 'min_fave_date' => $min_fave_date, 'max_fave_date' => $max_fave_date, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
781 | } |
---|
782 | |
---|
783 | function favorites_getPublicList ($user_id, $jump_to = NULL, $min_fave_date = NULL, $max_fave_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
784 | /* https://www.flickr.com/services/api/flickr.favorites.getPublicList.html */ |
---|
785 | return $this->call('flickr.favorites.getPublicList', array('user_id' => $user_id, 'jump_to' => $jump_to, 'min_fave_date' => $min_fave_date, 'max_fave_date' => $max_fave_date, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
786 | } |
---|
787 | |
---|
788 | function favorites_remove ($photo_id, $user_id = NULL) { |
---|
789 | /* https://www.flickr.com/services/api/flickr.favorites.remove.html */ |
---|
790 | $this->request("flickr.favorites.remove", array('photo_id' => $photo_id, 'user_id' => $user_id), TRUE); |
---|
791 | return $this->parsed_response ? true : false; |
---|
792 | } |
---|
793 | |
---|
794 | /* Galleries Methods */ |
---|
795 | function galleries_addPhoto ($gallery_id, $photo_id, $comment = NULL) { |
---|
796 | /* https://www.flickr.com/services/api/flickr.galleries.addPhoto.html */ |
---|
797 | return $this->call('flickr.galleries.addPhoto', array('gallery_id' => $gallery_id, 'photo_id' => $photo_id, 'comment' => $comment)); |
---|
798 | } |
---|
799 | |
---|
800 | function galleries_create ($title, $description, $primary_photo_id = NULL) { |
---|
801 | /* https://www.flickr.com/services/api/flickr.galleries.create.html */ |
---|
802 | return $this->call('flickr.galleries.create', array('title' => $title, 'description' => $description, 'primary_photo_id' => $primary_photo_id)); |
---|
803 | } |
---|
804 | |
---|
805 | function galleries_editMeta ($gallery_id, $title, $description = NULL) { |
---|
806 | /* https://www.flickr.com/services/api/flickr.galleries.editMeta.html */ |
---|
807 | return $this->call('flickr.galleries.editMeta', array('gallery_id' => $gallery_id, 'title' => $title, 'description' => $description)); |
---|
808 | } |
---|
809 | |
---|
810 | function galleries_editPhoto ($gallery_id, $photo_id, $comment) { |
---|
811 | /* https://www.flickr.com/services/api/flickr.galleries.editPhoto.html */ |
---|
812 | return $this->call('flickr.galleries.editPhoto', array('gallery_id' => $gallery_id, 'photo_id' => $photo_id, 'comment' => $comment)); |
---|
813 | } |
---|
814 | |
---|
815 | function galleries_editPhotos ($gallery_id, $primary_photo_id, $photo_ids) { |
---|
816 | /* https://www.flickr.com/services/api/flickr.galleries.editPhotos.html */ |
---|
817 | return $this->call('flickr.galleries.editPhotos', array('gallery_id' => $gallery_id, 'primary_photo_id' => $primary_photo_id, 'photo_ids' => $photo_ids)); |
---|
818 | } |
---|
819 | |
---|
820 | function galleries_getInfo ($gallery_id) { |
---|
821 | /* https://www.flickr.com/services/api/flickr.galleries.getInfo.html */ |
---|
822 | return $this->call('flickr.galleries.getInfo', array('gallery_id' => $gallery_id)); |
---|
823 | } |
---|
824 | |
---|
825 | function galleries_getList ($user_id, $per_page = NULL, $page = NULL) { |
---|
826 | /* https://www.flickr.com/services/api/flickr.galleries.getList.html */ |
---|
827 | return $this->call('flickr.galleries.getList', array('user_id' => $user_id, 'per_page' => $per_page, 'page' => $page)); |
---|
828 | } |
---|
829 | |
---|
830 | function galleries_getListForPhoto ($photo_id, $per_page = NULL, $page = NULL) { |
---|
831 | /* https://www.flickr.com/services/api/flickr.galleries.getListForPhoto.html */ |
---|
832 | return $this->call('flickr.galleries.getListForPhoto', array('photo_id' => $photo_id, 'per_page' => $per_page, 'page' => $page)); |
---|
833 | } |
---|
834 | |
---|
835 | function galleries_getPhotos ($gallery_id, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
836 | /* https://www.flickr.com/services/api/flickr.galleries.getPhotos.html */ |
---|
837 | return $this->call('flickr.galleries.getPhotos', array('gallery_id' => $gallery_id, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
838 | } |
---|
839 | |
---|
840 | /* Groups Methods */ |
---|
841 | function groups_browse ($cat_id = NULL) { |
---|
842 | /* https://www.flickr.com/services/api/flickr.groups.browse.html */ |
---|
843 | $this->request("flickr.groups.browse", array("cat_id"=>$cat_id)); |
---|
844 | return $this->parsed_response ? $this->parsed_response['category'] : false; |
---|
845 | } |
---|
846 | |
---|
847 | function groups_getInfo ($group_id, $lang = NULL) { |
---|
848 | /* https://www.flickr.com/services/api/flickr.groups.getInfo.html */ |
---|
849 | return $this->call('flickr.groups.getInfo', array('group_id' => $group_id, 'lang' => $lang)); |
---|
850 | } |
---|
851 | |
---|
852 | function groups_search ($text, $per_page = NULL, $page = NULL) { |
---|
853 | /* https://www.flickr.com/services/api/flickr.groups.search.html */ |
---|
854 | $this->request("flickr.groups.search", array("text"=>$text,"per_page"=>$per_page,"page"=>$page)); |
---|
855 | return $this->parsed_response ? $this->parsed_response['groups'] : false; |
---|
856 | } |
---|
857 | |
---|
858 | /* Groups Members Methods */ |
---|
859 | function groups_members_getList ($group_id, $membertypes = NULL, $per_page = NULL, $page = NULL) { |
---|
860 | /* https://www.flickr.com/services/api/flickr.groups.members.getList.html */ |
---|
861 | return $this->call('flickr.groups.members.getList', array('group_id' => $group_id, 'membertypes' => $membertypes, 'per_page' => $per_page, 'page' => $page)); |
---|
862 | } |
---|
863 | |
---|
864 | /* Groups Pools Methods */ |
---|
865 | function groups_pools_add ($photo_id, $group_id) { |
---|
866 | /* https://www.flickr.com/services/api/flickr.groups.pools.add.html */ |
---|
867 | $this->request("flickr.groups.pools.add", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE); |
---|
868 | return $this->parsed_response ? true : false; |
---|
869 | } |
---|
870 | |
---|
871 | function groups_pools_getContext ($photo_id, $group_id, $num_prev = NULL, $num_next = NULL) { |
---|
872 | /* https://www.flickr.com/services/api/flickr.groups.pools.getContext.html */ |
---|
873 | return $this->call('flickr.groups.pools.getContext', array('photo_id' => $photo_id, 'group_id' => $group_id, 'num_prev' => $num_prev, 'num_next' => $num_next)); |
---|
874 | } |
---|
875 | |
---|
876 | function groups_pools_getGroups ($page = NULL, $per_page = NULL) { |
---|
877 | /* https://www.flickr.com/services/api/flickr.groups.pools.getGroups.html */ |
---|
878 | $this->request("flickr.groups.pools.getGroups", array('page'=>$page, 'per_page'=>$per_page)); |
---|
879 | return $this->parsed_response ? $this->parsed_response['groups'] : false; |
---|
880 | } |
---|
881 | |
---|
882 | function groups_pools_getPhotos ($group_id, $tags = NULL, $user_id = NULL, $jump_to = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
883 | /* https://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html */ |
---|
884 | if (is_array($extras)) { |
---|
885 | $extras = implode(",", $extras); |
---|
886 | } |
---|
887 | return $this->call('flickr.groups.pools.getPhotos', array('group_id' => $group_id, 'tags' => $tags, 'user_id' => $user_id, 'jump_to' => $jump_to, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
888 | } |
---|
889 | |
---|
890 | function groups_pools_remove ($photo_id, $group_id) { |
---|
891 | /* https://www.flickr.com/services/api/flickr.groups.pools.remove.html */ |
---|
892 | $this->request("flickr.groups.pools.remove", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE); |
---|
893 | return $this->parsed_response ? true : false; |
---|
894 | } |
---|
895 | |
---|
896 | /* Interestingness methods */ |
---|
897 | function interestingness_getList ($date = NULL, $use_panda = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
898 | /* https://www.flickr.com/services/api/flickr.interestingness.getList.html */ |
---|
899 | if (is_array($extras)) { |
---|
900 | $extras = implode(",", $extras); |
---|
901 | } |
---|
902 | |
---|
903 | return $this->call('flickr.interestingness.getList', array('date' => $date, 'use_panda' => $use_panda, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
904 | } |
---|
905 | |
---|
906 | /* Machine Tag methods */ |
---|
907 | function machinetags_getNamespaces ($predicate = NULL, $per_page = NULL, $page = NULL) { |
---|
908 | /* https://www.flickr.com/services/api/flickr.machinetags.getNamespaces.html */ |
---|
909 | return $this->call('flickr.machinetags.getNamespaces', array('predicate' => $predicate, 'per_page' => $per_page, 'page' => $page)); |
---|
910 | } |
---|
911 | |
---|
912 | function machinetags_getPairs ($namespace = NULL, $predicate = NULL, $per_page = NULL, $page = NULL) { |
---|
913 | /* https://www.flickr.com/services/api/flickr.machinetags.getPairs.html */ |
---|
914 | return $this->call('flickr.machinetags.getPairs', array('namespace' => $namespace, 'predicate' => $predicate, 'per_page' => $per_page, 'page' => $page)); |
---|
915 | } |
---|
916 | |
---|
917 | function machinetags_getPredicates ($namespace = NULL, $per_page = NULL, $page = NULL) { |
---|
918 | /* https://www.flickr.com/services/api/flickr.machinetags.getPredicates.html */ |
---|
919 | return $this->call('flickr.machinetags.getPredicates', array('namespace' => $namespace, 'per_page' => $per_page, 'page' => $page)); |
---|
920 | } |
---|
921 | |
---|
922 | function machinetags_getRecentValues ($namespace = NULL, $predicate = NULL, $added_since = NULL) { |
---|
923 | /* https://www.flickr.com/services/api/flickr.machinetags.getRecentValues.html */ |
---|
924 | return $this->call('flickr.machinetags.getRecentValues', array('namespace' => $namespace, 'predicate' => $predicate, 'added_since' => $added_since)); |
---|
925 | } |
---|
926 | |
---|
927 | function machinetags_getValues ($namespace, $predicate, $per_page = NULL, $page = NULL, $usage = NULL) { |
---|
928 | /* https://www.flickr.com/services/api/flickr.machinetags.getValues.html */ |
---|
929 | return $this->call('flickr.machinetags.getValues', array('namespace' => $namespace, 'predicate' => $predicate, 'per_page' => $per_page, 'page' => $page, 'usage' => $usage)); |
---|
930 | } |
---|
931 | |
---|
932 | /* Panda methods */ |
---|
933 | function panda_getList () { |
---|
934 | /* https://www.flickr.com/services/api/flickr.panda.getList.html */ |
---|
935 | return $this->call('flickr.panda.getList', array()); |
---|
936 | } |
---|
937 | |
---|
938 | function panda_getPhotos ($panda_name, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
939 | /* https://www.flickr.com/services/api/flickr.panda.getPhotos.html */ |
---|
940 | return $this->call('flickr.panda.getPhotos', array('panda_name' => $panda_name, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
941 | } |
---|
942 | |
---|
943 | /* People methods */ |
---|
944 | function people_findByEmail ($find_email) { |
---|
945 | /* https://www.flickr.com/services/api/flickr.people.findByEmail.html */ |
---|
946 | $this->request("flickr.people.findByEmail", array("find_email"=>$find_email)); |
---|
947 | return $this->parsed_response ? $this->parsed_response['user'] : false; |
---|
948 | } |
---|
949 | |
---|
950 | function people_findByUsername ($username) { |
---|
951 | /* https://www.flickr.com/services/api/flickr.people.findByUsername.html */ |
---|
952 | $this->request("flickr.people.findByUsername", array("username"=>$username)); |
---|
953 | return $this->parsed_response ? $this->parsed_response['user'] : false; |
---|
954 | } |
---|
955 | |
---|
956 | function people_getInfo ($user_id) { |
---|
957 | /* https://www.flickr.com/services/api/flickr.people.getInfo.html */ |
---|
958 | $this->request("flickr.people.getInfo", array("user_id"=>$user_id)); |
---|
959 | return $this->parsed_response ? $this->parsed_response['person'] : false; |
---|
960 | } |
---|
961 | |
---|
962 | function people_getPhotos ($user_id, $args = array()) { |
---|
963 | /* This function strays from the method of arguments that I've |
---|
964 | * used in the other functions for the fact that there are just |
---|
965 | * so many arguments to this API method. What you'll need to do |
---|
966 | * is pass an associative array to the function containing the |
---|
967 | * arguments you want to pass to the API. For example: |
---|
968 | * $photos = $f->photos_search(array("tags"=>"brown,cow", "tag_mode"=>"any")); |
---|
969 | * This will return photos tagged with either "brown" or "cow" |
---|
970 | * or both. See the API documentation (link below) for a full |
---|
971 | * list of arguments. |
---|
972 | */ |
---|
973 | |
---|
974 | /* https://www.flickr.com/services/api/flickr.people.getPhotos.html */ |
---|
975 | return $this->call('flickr.people.getPhotos', array_merge(array('user_id' => $user_id), $args)); |
---|
976 | } |
---|
977 | |
---|
978 | function people_getPhotosOf ($user_id, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
979 | /* https://www.flickr.com/services/api/flickr.people.getPhotosOf.html */ |
---|
980 | return $this->call('flickr.people.getPhotosOf', array('user_id' => $user_id, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
981 | } |
---|
982 | |
---|
983 | function people_getPublicGroups ($user_id) { |
---|
984 | /* https://www.flickr.com/services/api/flickr.people.getPublicGroups.html */ |
---|
985 | $this->request("flickr.people.getPublicGroups", array("user_id"=>$user_id)); |
---|
986 | return $this->parsed_response ? $this->parsed_response['groups']['group'] : false; |
---|
987 | } |
---|
988 | |
---|
989 | function people_getPublicPhotos ($user_id, $safe_search = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
990 | /* https://www.flickr.com/services/api/flickr.people.getPublicPhotos.html */ |
---|
991 | return $this->call('flickr.people.getPublicPhotos', array('user_id' => $user_id, 'safe_search' => $safe_search, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
992 | } |
---|
993 | |
---|
994 | function people_getUploadStatus () { |
---|
995 | /* https://www.flickr.com/services/api/flickr.people.getUploadStatus.html */ |
---|
996 | /* Requires Authentication */ |
---|
997 | $this->request("flickr.people.getUploadStatus"); |
---|
998 | return $this->parsed_response ? $this->parsed_response['user'] : false; |
---|
999 | } |
---|
1000 | |
---|
1001 | |
---|
1002 | /* Photos Methods */ |
---|
1003 | function photos_addTags ($photo_id, $tags) { |
---|
1004 | /* https://www.flickr.com/services/api/flickr.photos.addTags.html */ |
---|
1005 | $this->request("flickr.photos.addTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE); |
---|
1006 | return $this->parsed_response ? true : false; |
---|
1007 | } |
---|
1008 | |
---|
1009 | function photos_delete ($photo_id) { |
---|
1010 | /* https://www.flickr.com/services/api/flickr.photos.delete.html */ |
---|
1011 | $this->request("flickr.photos.delete", array("photo_id"=>$photo_id), TRUE); |
---|
1012 | return $this->parsed_response ? true : false; |
---|
1013 | } |
---|
1014 | |
---|
1015 | function photos_getAllContexts ($photo_id) { |
---|
1016 | /* https://www.flickr.com/services/api/flickr.photos.getAllContexts.html */ |
---|
1017 | $this->request("flickr.photos.getAllContexts", array("photo_id"=>$photo_id)); |
---|
1018 | return $this->parsed_response ? $this->parsed_response : false; |
---|
1019 | } |
---|
1020 | |
---|
1021 | function photos_getContactsPhotos ($count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL) { |
---|
1022 | /* https://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html */ |
---|
1023 | $this->request("flickr.photos.getContactsPhotos", array("count"=>$count, "just_friends"=>$just_friends, "single_photo"=>$single_photo, "include_self"=>$include_self, "extras"=>$extras)); |
---|
1024 | return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false; |
---|
1025 | } |
---|
1026 | |
---|
1027 | function photos_getContactsPublicPhotos ($user_id, $count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL) { |
---|
1028 | /* https://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html */ |
---|
1029 | $this->request("flickr.photos.getContactsPublicPhotos", array("user_id"=>$user_id, "count"=>$count, "just_friends"=>$just_friends, "single_photo"=>$single_photo, "include_self"=>$include_self, "extras"=>$extras)); |
---|
1030 | return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false; |
---|
1031 | } |
---|
1032 | |
---|
1033 | function photos_getContext ($photo_id, $num_prev = NULL, $num_next = NULL, $extras = NULL, $order_by = NULL) { |
---|
1034 | /* https://www.flickr.com/services/api/flickr.photos.getContext.html */ |
---|
1035 | return $this->call('flickr.photos.getContext', array('photo_id' => $photo_id, 'num_prev' => $num_prev, 'num_next' => $num_next, 'extras' => $extras, 'order_by' => $order_by)); |
---|
1036 | } |
---|
1037 | |
---|
1038 | function photos_getCounts ($dates = NULL, $taken_dates = NULL) { |
---|
1039 | /* https://www.flickr.com/services/api/flickr.photos.getCounts.html */ |
---|
1040 | $this->request("flickr.photos.getCounts", array("dates"=>$dates, "taken_dates"=>$taken_dates)); |
---|
1041 | return $this->parsed_response ? $this->parsed_response['photocounts']['photocount'] : false; |
---|
1042 | } |
---|
1043 | |
---|
1044 | function photos_getExif ($photo_id, $secret = NULL) { |
---|
1045 | /* https://www.flickr.com/services/api/flickr.photos.getExif.html */ |
---|
1046 | $this->request("flickr.photos.getExif", array("photo_id"=>$photo_id, "secret"=>$secret)); |
---|
1047 | return $this->parsed_response ? $this->parsed_response['photo'] : false; |
---|
1048 | } |
---|
1049 | |
---|
1050 | function photos_getFavorites ($photo_id, $page = NULL, $per_page = NULL) { |
---|
1051 | /* https://www.flickr.com/services/api/flickr.photos.getFavorites.html */ |
---|
1052 | $this->request("flickr.photos.getFavorites", array("photo_id"=>$photo_id, "page"=>$page, "per_page"=>$per_page)); |
---|
1053 | return $this->parsed_response ? $this->parsed_response['photo'] : false; |
---|
1054 | } |
---|
1055 | |
---|
1056 | function photos_getInfo ($photo_id, $secret = NULL, $humandates = NULL, $privacy_filter = NULL, $get_contexts = NULL) { |
---|
1057 | /* https://www.flickr.com/services/api/flickr.photos.getInfo.html */ |
---|
1058 | return $this->call('flickr.photos.getInfo', array('photo_id' => $photo_id, 'secret' => $secret, 'humandates' => $humandates, 'privacy_filter' => $privacy_filter, 'get_contexts' => $get_contexts)); |
---|
1059 | } |
---|
1060 | |
---|
1061 | function photos_getNotInSet ($max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $media = NULL, $min_upload_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
1062 | /* https://www.flickr.com/services/api/flickr.photos.getNotInSet.html */ |
---|
1063 | return $this->call('flickr.photos.getNotInSet', array('max_upload_date' => $max_upload_date, 'min_taken_date' => $min_taken_date, 'max_taken_date' => $max_taken_date, 'privacy_filter' => $privacy_filter, 'media' => $media, 'min_upload_date' => $min_upload_date, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
1064 | } |
---|
1065 | |
---|
1066 | function photos_getPerms ($photo_id) { |
---|
1067 | /* https://www.flickr.com/services/api/flickr.photos.getPerms.html */ |
---|
1068 | $this->request("flickr.photos.getPerms", array("photo_id"=>$photo_id)); |
---|
1069 | return $this->parsed_response ? $this->parsed_response['perms'] : false; |
---|
1070 | } |
---|
1071 | |
---|
1072 | function photos_getRecent ($jump_to = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
1073 | /* https://www.flickr.com/services/api/flickr.photos.getRecent.html */ |
---|
1074 | if (is_array($extras)) { |
---|
1075 | $extras = implode(",", $extras); |
---|
1076 | } |
---|
1077 | return $this->call('flickr.photos.getRecent', array('jump_to' => $jump_to, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
1078 | } |
---|
1079 | |
---|
1080 | function photos_getSizes ($photo_id) { |
---|
1081 | /* https://www.flickr.com/services/api/flickr.photos.getSizes.html */ |
---|
1082 | $this->request("flickr.photos.getSizes", array("photo_id"=>$photo_id)); |
---|
1083 | return $this->parsed_response ? $this->parsed_response['sizes']['size'] : false; |
---|
1084 | } |
---|
1085 | |
---|
1086 | function photos_getUntagged ($min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $media = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
1087 | /* https://www.flickr.com/services/api/flickr.photos.getUntagged.html */ |
---|
1088 | return $this->call('flickr.photos.getUntagged', array('min_upload_date' => $min_upload_date, 'max_upload_date' => $max_upload_date, 'min_taken_date' => $min_taken_date, 'max_taken_date' => $max_taken_date, 'privacy_filter' => $privacy_filter, 'media' => $media, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
1089 | } |
---|
1090 | |
---|
1091 | function photos_getWithGeoData ($args = array()) { |
---|
1092 | /* See the documentation included with the photos_search() function. |
---|
1093 | * I'm using the same style of arguments for this function. The only |
---|
1094 | * difference here is that this doesn't require any arguments. The |
---|
1095 | * flickr.photos.search method requires at least one search parameter. |
---|
1096 | */ |
---|
1097 | /* https://www.flickr.com/services/api/flickr.photos.getWithGeoData.html */ |
---|
1098 | $this->request("flickr.photos.getWithGeoData", $args); |
---|
1099 | return $this->parsed_response ? $this->parsed_response['photos'] : false; |
---|
1100 | } |
---|
1101 | |
---|
1102 | function photos_getWithoutGeoData ($args = array()) { |
---|
1103 | /* See the documentation included with the photos_search() function. |
---|
1104 | * I'm using the same style of arguments for this function. The only |
---|
1105 | * difference here is that this doesn't require any arguments. The |
---|
1106 | * flickr.photos.search method requires at least one search parameter. |
---|
1107 | */ |
---|
1108 | /* https://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html */ |
---|
1109 | $this->request("flickr.photos.getWithoutGeoData", $args); |
---|
1110 | return $this->parsed_response ? $this->parsed_response['photos'] : false; |
---|
1111 | } |
---|
1112 | |
---|
1113 | function photos_recentlyUpdated ($min_date, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
1114 | /* https://www.flickr.com/services/api/flickr.photos.recentlyUpdated.html */ |
---|
1115 | return $this->call('flickr.photos.recentlyUpdated', array('min_date' => $min_date, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
1116 | } |
---|
1117 | |
---|
1118 | function photos_removeTag ($tag_id) { |
---|
1119 | /* https://www.flickr.com/services/api/flickr.photos.removeTag.html */ |
---|
1120 | $this->request("flickr.photos.removeTag", array("tag_id"=>$tag_id), TRUE); |
---|
1121 | return $this->parsed_response ? true : false; |
---|
1122 | } |
---|
1123 | |
---|
1124 | function photos_search ($args = array()) { |
---|
1125 | /* This function strays from the method of arguments that I've |
---|
1126 | * used in the other functions for the fact that there are just |
---|
1127 | * so many arguments to this API method. What you'll need to do |
---|
1128 | * is pass an associative array to the function containing the |
---|
1129 | * arguments you want to pass to the API. For example: |
---|
1130 | * $photos = $f->photos_search(array("tags"=>"brown,cow", "tag_mode"=>"any")); |
---|
1131 | * This will return photos tagged with either "brown" or "cow" |
---|
1132 | * or both. See the API documentation (link below) for a full |
---|
1133 | * list of arguments. |
---|
1134 | */ |
---|
1135 | |
---|
1136 | /* https://www.flickr.com/services/api/flickr.photos.search.html */ |
---|
1137 | $this->request("flickr.photos.search", $args); |
---|
1138 | return $this->parsed_response ? $this->parsed_response['photos'] : false; |
---|
1139 | } |
---|
1140 | |
---|
1141 | function photos_setContentType ($photo_id, $content_type) { |
---|
1142 | /* https://www.flickr.com/services/api/flickr.photos.setContentType.html */ |
---|
1143 | return $this->call('flickr.photos.setContentType', array('photo_id' => $photo_id, 'content_type' => $content_type)); |
---|
1144 | } |
---|
1145 | |
---|
1146 | function photos_setDates ($photo_id, $date_posted = NULL, $date_taken = NULL, $date_taken_granularity = NULL) { |
---|
1147 | /* https://www.flickr.com/services/api/flickr.photos.setDates.html */ |
---|
1148 | $this->request("flickr.photos.setDates", array("photo_id"=>$photo_id, "date_posted"=>$date_posted, "date_taken"=>$date_taken, "date_taken_granularity"=>$date_taken_granularity), TRUE); |
---|
1149 | return $this->parsed_response ? true : false; |
---|
1150 | } |
---|
1151 | |
---|
1152 | function photos_setMeta ($photo_id, $title, $description) { |
---|
1153 | /* https://www.flickr.com/services/api/flickr.photos.setMeta.html */ |
---|
1154 | $this->request("flickr.photos.setMeta", array("photo_id"=>$photo_id, "title"=>$title, "description"=>$description), TRUE); |
---|
1155 | return $this->parsed_response ? true : false; |
---|
1156 | } |
---|
1157 | |
---|
1158 | function photos_setPerms ($photo_id, $is_public, $is_friend, $is_family, $perm_comment, $perm_addmeta) { |
---|
1159 | /* https://www.flickr.com/services/api/flickr.photos.setPerms.html */ |
---|
1160 | $this->request("flickr.photos.setPerms", array("photo_id"=>$photo_id, "is_public"=>$is_public, "is_friend"=>$is_friend, "is_family"=>$is_family, "perm_comment"=>$perm_comment, "perm_addmeta"=>$perm_addmeta), TRUE); |
---|
1161 | return $this->parsed_response ? true : false; |
---|
1162 | } |
---|
1163 | |
---|
1164 | function photos_setSafetyLevel ($photo_id, $safety_level = NULL, $hidden = NULL) { |
---|
1165 | /* https://www.flickr.com/services/api/flickr.photos.setSafetyLevel.html */ |
---|
1166 | return $this->call('flickr.photos.setSafetyLevel', array('photo_id' => $photo_id, 'safety_level' => $safety_level, 'hidden' => $hidden)); |
---|
1167 | } |
---|
1168 | |
---|
1169 | function photos_setTags ($photo_id, $tags) { |
---|
1170 | /* https://www.flickr.com/services/api/flickr.photos.setTags.html */ |
---|
1171 | $this->request("flickr.photos.setTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE); |
---|
1172 | return $this->parsed_response ? true : false; |
---|
1173 | } |
---|
1174 | |
---|
1175 | /* Photos - Comments Methods */ |
---|
1176 | function photos_comments_addComment ($photo_id, $comment_text) { |
---|
1177 | /* https://www.flickr.com/services/api/flickr.photos.comments.addComment.html */ |
---|
1178 | $this->request("flickr.photos.comments.addComment", array("photo_id" => $photo_id, "comment_text"=>$comment_text), TRUE); |
---|
1179 | return $this->parsed_response ? $this->parsed_response['comment'] : false; |
---|
1180 | } |
---|
1181 | |
---|
1182 | function photos_comments_deleteComment ($comment_id) { |
---|
1183 | /* https://www.flickr.com/services/api/flickr.photos.comments.deleteComment.html */ |
---|
1184 | $this->request("flickr.photos.comments.deleteComment", array("comment_id" => $comment_id), TRUE); |
---|
1185 | return $this->parsed_response ? true : false; |
---|
1186 | } |
---|
1187 | |
---|
1188 | function photos_comments_editComment ($comment_id, $comment_text) { |
---|
1189 | /* https://www.flickr.com/services/api/flickr.photos.comments.editComment.html */ |
---|
1190 | $this->request("flickr.photos.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE); |
---|
1191 | return $this->parsed_response ? true : false; |
---|
1192 | } |
---|
1193 | |
---|
1194 | function photos_comments_getList ($photo_id, $min_comment_date = NULL, $max_comment_date = NULL, $page = NULL, $per_page = NULL, $include_faves = NULL) { |
---|
1195 | /* https://www.flickr.com/services/api/flickr.photos.comments.getList.html */ |
---|
1196 | return $this->call('flickr.photos.comments.getList', array('photo_id' => $photo_id, 'min_comment_date' => $min_comment_date, 'max_comment_date' => $max_comment_date, 'page' => $page, 'per_page' => $per_page, 'include_faves' => $include_faves)); |
---|
1197 | } |
---|
1198 | |
---|
1199 | function photos_comments_getRecentForContacts ($date_lastcomment = NULL, $contacts_filter = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
1200 | /* https://www.flickr.com/services/api/flickr.photos.comments.getRecentForContacts.html */ |
---|
1201 | return $this->call('flickr.photos.comments.getRecentForContacts', array('date_lastcomment' => $date_lastcomment, 'contacts_filter' => $contacts_filter, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
1202 | } |
---|
1203 | |
---|
1204 | /* Photos - Geo Methods */ |
---|
1205 | function photos_geo_batchCorrectLocation ($lat, $lon, $accuracy, $place_id = NULL, $woe_id = NULL) { |
---|
1206 | /* https://www.flickr.com/services/api/flickr.photos.geo.batchCorrectLocation.html */ |
---|
1207 | return $this->call('flickr.photos.geo.batchCorrectLocation', array('lat' => $lat, 'lon' => $lon, 'accuracy' => $accuracy, 'place_id' => $place_id, 'woe_id' => $woe_id)); |
---|
1208 | } |
---|
1209 | |
---|
1210 | function photos_geo_correctLocation ($photo_id, $place_id = NULL, $woe_id = NULL) { |
---|
1211 | /* https://www.flickr.com/services/api/flickr.photos.geo.correctLocation.html */ |
---|
1212 | return $this->call('flickr.photos.geo.correctLocation', array('photo_id' => $photo_id, 'place_id' => $place_id, 'woe_id' => $woe_id)); |
---|
1213 | } |
---|
1214 | |
---|
1215 | function photos_geo_getLocation ($photo_id) { |
---|
1216 | /* https://www.flickr.com/services/api/flickr.photos.geo.getLocation.html */ |
---|
1217 | $this->request("flickr.photos.geo.getLocation", array("photo_id"=>$photo_id)); |
---|
1218 | return $this->parsed_response ? $this->parsed_response['photo'] : false; |
---|
1219 | } |
---|
1220 | |
---|
1221 | function photos_geo_getPerms ($photo_id) { |
---|
1222 | /* https://www.flickr.com/services/api/flickr.photos.geo.getPerms.html */ |
---|
1223 | $this->request("flickr.photos.geo.getPerms", array("photo_id"=>$photo_id)); |
---|
1224 | return $this->parsed_response ? $this->parsed_response['perms'] : false; |
---|
1225 | } |
---|
1226 | |
---|
1227 | function photos_geo_photosForLocation ($lat, $lon, $accuracy = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { |
---|
1228 | /* https://www.flickr.com/services/api/flickr.photos.geo.photosForLocation.html */ |
---|
1229 | return $this->call('flickr.photos.geo.photosForLocation', array('lat' => $lat, 'lon' => $lon, 'accuracy' => $accuracy, 'extras' => $extras, 'per_page' => $per_page, 'page' => $page)); |
---|
1230 | } |
---|
1231 | |
---|
1232 | function photos_geo_removeLocation ($photo_id) { |
---|
1233 | /* https://www.flickr.com/services/api/flickr.photos.geo.removeLocation.html */ |
---|
1234 | $this->request("flickr.photos.geo.removeLocation", array("photo_id"=>$photo_id), TRUE); |
---|
1235 | return $this->parsed_response ? true : false; |
---|
1236 | } |
---|
1237 | |
---|
1238 | function photos_geo_setContext ($photo_id, $context) { |
---|
1239 | /* https://www.flickr.com/services/api/flickr.photos.geo.setContext.html */ |
---|
1240 | return $this->call('flickr.photos.geo.setContext', array('photo_id' => $photo_id, 'context' => $context)); |
---|
1241 | } |
---|
1242 | |
---|
1243 | function photos_geo_setLocation ($photo_id, $lat, $lon, $accuracy = NULL, $context = NULL, $bookmark_id = NULL) { |
---|
1244 | /* https://www.flickr.com/services/api/flickr.photos.geo.setLocation.html */ |
---|
1245 | return $this->call('flickr.photos.geo.setLocation', array('photo_id' => $photo_id, 'lat' => $lat, 'lon' => $lon, 'accuracy' => $accuracy, 'context' => $context, 'bookmark_id' => $bookmark_id)); |
---|
1246 | } |
---|
1247 | |
---|
1248 | function photos_geo_setPerms ($is_public, $is_contact, $is_friend, $is_family, $photo_id) { |
---|
1249 | /* https://www.flickr.com/services/api/flickr.photos.geo.setPerms.html */ |
---|
1250 | return $this->call('flickr.photos.geo.setPerms', array('is_public' => $is_public, 'is_contact' => $is_contact, 'is_friend' => $is_friend, 'is_family' => $is_family, 'photo_id' => $photo_id)); |
---|
1251 | } |
---|
1252 | |
---|
1253 | /* Photos - Licenses Methods */ |
---|
1254 | function photos_licenses_getInfo () { |
---|
1255 | /* https://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html */ |
---|
1256 | $this->request("flickr.photos.licenses.getInfo"); |
---|
1257 | return $this->parsed_response ? $this->parsed_response['licenses']['license'] : false; |
---|
1258 | } |
---|
1259 | |
---|
1260 | function photos_licenses_setLicense ($photo_id, $license_id) { |
---|
1261 | /* https://www.flickr.com/services/api/flickr.photos.licenses.setLicense.html */ |
---|
1262 | /* Requires Authentication */ |
---|
1263 | $this->request("flickr.photos.licenses.setLicense", array("photo_id"=>$photo_id, "license_id"=>$license_id), TRUE); |
---|
1264 | return $this->parsed_response ? true : false; |
---|
1265 | } |
---|
1266 | |
---|
1267 | /* Photos - Notes Methods */ |
---|
1268 | function photos_notes_add ($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text) { |
---|
1269 | /* https://www.flickr.com/services/api/flickr.photos.notes.add.html */ |
---|
1270 | $this->request("flickr.photos.notes.add", array("photo_id" => $photo_id, "note_x" => $note_x, "note_y" => $note_y, "note_w" => $note_w, "note_h" => $note_h, "note_text" => $note_text), TRUE); |
---|
1271 | return $this->parsed_response ? $this->parsed_response['note'] : false; |
---|
1272 | } |
---|
1273 | |
---|
1274 | function photos_notes_delete ($note_id) { |
---|
1275 | /* https://www.flickr.com/services/api/flickr.photos.notes.delete.html */ |
---|
1276 | $this->request("flickr.photos.notes.delete", array("note_id" => $note_id), TRUE); |
---|
1277 | return $this->parsed_response ? true : false; |
---|
1278 | } |
---|
1279 | |
---|
1280 | function photos_notes_edit ($note_id, $note_x, $note_y, $note_w, $note_h, $note_text) { |
---|
1281 | /* https://www.flickr.com/services/api/flickr.photos.notes.edit.html */ |
---|
1282 | $this->request("flickr.photos.notes.edit", array("note_id" => $note_id, "note_x" => $note_x, "note_y" => $note_y, "note_w" => $note_w, "note_h" => $note_h, "note_text" => $note_text), TRUE); |
---|
1283 | return $this->parsed_response ? true : false; |
---|
1284 | } |
---|
1285 | |
---|
1286 | /* Photos - Transform Methods */ |
---|
1287 | function photos_transform_rotate ($photo_id, $degrees) { |
---|
1288 | /* https://www.flickr.com/services/api/flickr.photos.transform.rotate.html */ |
---|
1289 | $this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE); |
---|
1290 | return $this->parsed_response ? true : false; |
---|
1291 | } |
---|
1292 | |
---|
1293 | /* Photos - People Methods */ |
---|
1294 | function photos_people_add ($photo_id, $user_id, $person_x = NULL, $person_y = NULL, $person_w = NULL, $person_h = NULL) { |
---|
1295 | /* https://www.flickr.com/services/api/flickr.photos.people.add.html */ |
---|
1296 | return $this->call('flickr.photos.people.add', array('photo_id' => $photo_id, 'user_id' => $user_id, 'person_x' => $person_x, 'person_y' => $person_y, 'person_w' => $person_w, 'person_h' => $person_h)); |
---|
1297 | } |
---|
1298 | |
---|
1299 | function photos_people_delete ($photo_id, $user_id, $email = NULL) { |
---|
1300 | /* https://www.flickr.com/services/api/flickr.photos.people.delete.html */ |
---|
1301 | return $this->call('flickr.photos.people.delete', array('photo_id' => $photo_id, 'user_id' => $user_id, 'email' => $email)); |
---|
1302 | } |
---|
1303 | |
---|
1304 | function photos_people_deleteCoords ($photo_id, $user_id) { |
---|
1305 | /* https://www.flickr.com/services/api/flickr.photos.people.deleteCoords.html */ |
---|
1306 | return $this->call('flickr.photos.people.deleteCoords', array('photo_id' => $photo_id, 'user_id' => $user_id)); |
---|
1307 | } |
---|
1308 | |
---|
1309 | function photos_people_editCoords ($photo_id, $user_id, $person_x, $person_y, $person_w, $person_h, $email = NULL) { |
---|
1310 | /* https://www.flickr.com/services/api/flickr.photos.people.editCoords.html */ |
---|
1311 | return $this->call('flickr.photos.people.editCoords', array('photo_id' => $photo_id, 'user_id' => $user_id, 'person_x' => $person_x, 'person_y' => $person_y, 'person_w' => $person_w, 'person_h' => $person_h, 'email' => $email)); |
---|
1312 | } |
---|
1313 | |
---|
1314 | function photos_people_getList ($photo_id) { |
---|
1315 | /* https://www.flickr.com/services/api/flickr.photos.people.getList.html */ |
---|
1316 | return $this->call('flickr.photos.people.getList', array('photo_id' => $photo_id)); |
---|
1317 | } |
---|
1318 | |
---|
1319 | /* Photos - Upload Methods */ |
---|
1320 | function photos_upload_checkTickets ($tickets) { |
---|
1321 | /* https://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html */ |
---|
1322 | if (is_array($tickets)) { |
---|
1323 | $tickets = implode(",", $tickets); |
---|
1324 | } |
---|
1325 | $this->request("flickr.photos.upload.checkTickets", array("tickets" => $tickets), TRUE); |
---|
1326 | return $this->parsed_response ? $this->parsed_response['uploader']['ticket'] : false; |
---|
1327 | } |
---|
1328 | |
---|
1329 | /* Photosets Methods */ |
---|
1330 | function photosets_addPhoto ($photoset_id, $photo_id) { |
---|
1331 | /* https://www.flickr.com/services/api/flickr.photosets.addPhoto.html */ |
---|
1332 | $this->request("flickr.photosets.addPhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE); |
---|
1333 | return $this->parsed_response ? true : false; |
---|
1334 | } |
---|
1335 | |
---|
1336 | function photosets_create ($title, $description, $primary_photo_id) { |
---|
1337 | /* https://www.flickr.com/services/api/flickr.photosets.create.html */ |
---|
1338 | $this->request("flickr.photosets.create", array("title" => $title, "primary_photo_id" => $primary_photo_id, "description" => $description), TRUE); |
---|
1339 | return $this->parsed_response ? $this->parsed_response['photoset'] : false; |
---|
1340 | } |
---|
1341 | |
---|
1342 | function photosets_delete ($photoset_id) { |
---|
1343 | /* https://www.flickr.com/services/api/flickr.photosets.delete.html */ |
---|
1344 | $this->request("flickr.photosets.delete", array("photoset_id" => $photoset_id), TRUE); |
---|
1345 | return $this->parsed_response ? true : false; |
---|
1346 | } |
---|
1347 | |
---|
1348 | function photosets_editMeta ($photoset_id, $title, $description = NULL) { |
---|
1349 | /* https://www.flickr.com/services/api/flickr.photosets.editMeta.html */ |
---|
1350 | $this->request("flickr.photosets.editMeta", array("photoset_id" => $photoset_id, "title" => $title, "description" => $description), TRUE); |
---|
1351 | return $this->parsed_response ? true : false; |
---|
1352 | } |
---|
1353 | |
---|
1354 | function photosets_editPhotos ($photoset_id, $primary_photo_id, $photo_ids) { |
---|
1355 | /* https://www.flickr.com/services/api/flickr.photosets.editPhotos.html */ |
---|
1356 | $this->request("flickr.photosets.editPhotos", array("photoset_id" => $photoset_id, "primary_photo_id" => $primary_photo_id, "photo_ids" => $photo_ids), TRUE); |
---|
1357 | return $this->parsed_response ? true : false; |
---|
1358 | } |
---|
1359 | |
---|
1360 | function photosets_getContext ($photo_id, $photoset_id, $num_prev = NULL, $num_next = NULL) { |
---|
1361 | /* https://www.flickr.com/services/api/flickr.photosets.getContext.html */ |
---|
1362 | return $this->call('flickr.photosets.getContext', array('photo_id' => $photo_id, 'photoset_id' => $photoset_id, 'num_prev' => $num_prev, 'num_next' => $num_next)); |
---|
1363 | } |
---|
1364 | |
---|
1365 | function photosets_getInfo ($photoset_id) { |
---|
1366 | /* https://www.flickr.com/services/api/flickr.photosets.getInfo.html */ |
---|
1367 | $this->request("flickr.photosets.getInfo", array("photoset_id" => $photoset_id)); |
---|
1368 | return $this->parsed_response ? $this->parsed_response['photoset'] : false; |
---|
1369 | } |
---|
1370 | |
---|
1371 | function photosets_getList ($user_id = NULL, $page = NULL, $per_page = NULL, $primary_photo_extras = NULL) { |
---|
1372 | /* https://www.flickr.com/services/api/flickr.photosets.getList.html */ |
---|
1373 | $this->request("flickr.photosets.getList", array("user_id" => $user_id, 'page' => $page, 'per_page' => $per_page, 'primary_photo_extras' => $primary_photo_extras)); |
---|
1374 | return $this->parsed_response ? $this->parsed_response['photosets'] : false; |
---|
1375 | } |
---|
1376 | |
---|
1377 | function photosets_getPhotos ($photoset_id, $extras = NULL, $privacy_filter = NULL, $per_page = NULL, $page = NULL, $media = NULL) { |
---|
1378 | /* https://www.flickr.com/services/api/flickr.photosets.getPhotos.html */ |
---|
1379 | return $this->call('flickr.photosets.getPhotos', array('photoset_id' => $photoset_id, 'extras' => $extras, 'privacy_filter' => $privacy_filter, 'per_page' => $per_page, 'page' => $page, 'media' => $media)); |
---|
1380 | } |
---|
1381 | |
---|
1382 | function photosets_orderSets ($photoset_ids) { |
---|
1383 | /* https://www.flickr.com/services/api/flickr.photosets.orderSets.html */ |
---|
1384 | if (is_array($photoset_ids)) { |
---|
1385 | $photoset_ids = implode(",", $photoset_ids); |
---|
1386 | } |
---|
1387 | $this->request("flickr.photosets.orderSets", array("photoset_ids" => $photoset_ids), TRUE); |
---|
1388 | return $this->parsed_response ? true : false; |
---|
1389 | } |
---|
1390 | |
---|
1391 | function photosets_removePhoto ($photoset_id, $photo_id) { |
---|
1392 | /* https://www.flickr.com/services/api/flickr.photosets.removePhoto.html */ |
---|
1393 | $this->request("flickr.photosets.removePhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE); |
---|
1394 | return $this->parsed_response ? true : false; |
---|
1395 | } |
---|
1396 | |
---|
1397 | function photosets_removePhotos ($photoset_id, $photo_ids) { |
---|
1398 | /* https://www.flickr.com/services/api/flickr.photosets.removePhotos.html */ |
---|
1399 | return $this->call('flickr.photosets.removePhotos', array('photoset_id' => $photoset_id, 'photo_ids' => $photo_ids)); |
---|
1400 | } |
---|
1401 | |
---|
1402 | function photosets_reorderPhotos ($photoset_id, $photo_ids) { |
---|
1403 | /* https://www.flickr.com/services/api/flickr.photosets.reorderPhotos.html */ |
---|
1404 | return $this->call('flickr.photosets.reorderPhotos', array('photoset_id' => $photoset_id, 'photo_ids' => $photo_ids)); |
---|
1405 | } |
---|
1406 | |
---|
1407 | function photosets_setPrimaryPhoto ($photoset_id, $photo_id) { |
---|
1408 | /* https://www.flickr.com/services/api/flickr.photosets.setPrimaryPhoto.html */ |
---|
1409 | return $this->call('flickr.photosets.setPrimaryPhoto', array('photoset_id' => $photoset_id, 'photo_id' => $photo_id)); |
---|
1410 | } |
---|
1411 | |
---|
1412 | /* Photosets Comments Methods */ |
---|
1413 | function photosets_comments_addComment ($photoset_id, $comment_text) { |
---|
1414 | /* https://www.flickr.com/services/api/flickr.photosets.comments.addComment.html */ |
---|
1415 | $this->request("flickr.photosets.comments.addComment", array("photoset_id" => $photoset_id, "comment_text"=>$comment_text), TRUE); |
---|
1416 | return $this->parsed_response ? $this->parsed_response['comment'] : false; |
---|
1417 | } |
---|
1418 | |
---|
1419 | function photosets_comments_deleteComment ($comment_id) { |
---|
1420 | /* https://www.flickr.com/services/api/flickr.photosets.comments.deleteComment.html */ |
---|
1421 | $this->request("flickr.photosets.comments.deleteComment", array("comment_id" => $comment_id), TRUE); |
---|
1422 | return $this->parsed_response ? true : false; |
---|
1423 | } |
---|
1424 | |
---|
1425 | function photosets_comments_editComment ($comment_id, $comment_text) { |
---|
1426 | /* https://www.flickr.com/services/api/flickr.photosets.comments.editComment.html */ |
---|
1427 | $this->request("flickr.photosets.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE); |
---|
1428 | return $this->parsed_response ? true : false; |
---|
1429 | } |
---|
1430 | |
---|
1431 | function photosets_comments_getList ($photoset_id) { |
---|
1432 | /* https://www.flickr.com/services/api/flickr.photosets.comments.getList.html */ |
---|
1433 | $this->request("flickr.photosets.comments.getList", array("photoset_id"=>$photoset_id)); |
---|
1434 | return $this->parsed_response ? $this->parsed_response['comments'] : false; |
---|
1435 | } |
---|
1436 | |
---|
1437 | /* Places Methods */ |
---|
1438 | function places_find ($query) { |
---|
1439 | /* https://www.flickr.com/services/api/flickr.places.find.html */ |
---|
1440 | return $this->call('flickr.places.find', array('query' => $query)); |
---|
1441 | } |
---|
1442 | |
---|
1443 | function places_findByLatLon ($lat, $lon, $accuracy = NULL) { |
---|
1444 | /* https://www.flickr.com/services/api/flickr.places.findByLatLon.html */ |
---|
1445 | return $this->call('flickr.places.findByLatLon', array('lat' => $lat, 'lon' => $lon, 'accuracy' => $accuracy)); |
---|
1446 | } |
---|
1447 | |
---|
1448 | function places_getChildrenWithPhotosPublic ($place_id = NULL, $woe_id = NULL) { |
---|
1449 | /* https://www.flickr.com/services/api/flickr.places.getChildrenWithPhotosPublic.html */ |
---|
1450 | return $this->call('flickr.places.getChildrenWithPhotosPublic', array('place_id' => $place_id, 'woe_id' => $woe_id)); |
---|
1451 | } |
---|
1452 | |
---|
1453 | function places_getInfo ($place_id = NULL, $woe_id = NULL) { |
---|
1454 | /* https://www.flickr.com/services/api/flickr.places.getInfo.html */ |
---|
1455 | return $this->call('flickr.places.getInfo', array('place_id' => $place_id, 'woe_id' => $woe_id)); |
---|
1456 | } |
---|
1457 | |
---|
1458 | function places_getInfoByUrl ($url) { |
---|
1459 | /* https://www.flickr.com/services/api/flickr.places.getInfoByUrl.html */ |
---|
1460 | return $this->call('flickr.places.getInfoByUrl', array('url' => $url)); |
---|
1461 | } |
---|
1462 | |
---|
1463 | function places_getPlaceTypes () { |
---|
1464 | /* https://www.flickr.com/services/api/flickr.places.getPlaceTypes.html */ |
---|
1465 | return $this->call('flickr.places.getPlaceTypes', array()); |
---|
1466 | } |
---|
1467 | |
---|
1468 | function places_getShapeHistory ($place_id = NULL, $woe_id = NULL) { |
---|
1469 | /* https://www.flickr.com/services/api/flickr.places.getShapeHistory.html */ |
---|
1470 | return $this->call('flickr.places.getShapeHistory', array('place_id' => $place_id, 'woe_id' => $woe_id)); |
---|
1471 | } |
---|
1472 | |
---|
1473 | function places_getTopPlacesList ($place_type_id, $date = NULL, $woe_id = NULL, $place_id = NULL) { |
---|
1474 | /* https://www.flickr.com/services/api/flickr.places.getTopPlacesList.html */ |
---|
1475 | return $this->call('flickr.places.getTopPlacesList', array('place_type_id' => $place_type_id, 'date' => $date, 'woe_id' => $woe_id, 'place_id' => $place_id)); |
---|
1476 | } |
---|
1477 | |
---|
1478 | function places_placesForBoundingBox ($bbox, $place_type = NULL, $place_type_id = NULL, $recursive = NULL) { |
---|
1479 | /* https://www.flickr.com/services/api/flickr.places.placesForBoundingBox.html */ |
---|
1480 | return $this->call('flickr.places.placesForBoundingBox', array('bbox' => $bbox, 'place_type' => $place_type, 'place_type_id' => $place_type_id, 'recursive' => $recursive)); |
---|
1481 | } |
---|
1482 | |
---|
1483 | function places_placesForContacts ($place_type = NULL, $place_type_id = NULL, $woe_id = NULL, $place_id = NULL, $threshold = NULL, $contacts = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) { |
---|
1484 | /* https://www.flickr.com/services/api/flickr.places.placesForContacts.html */ |
---|
1485 | return $this->call('flickr.places.placesForContacts', array('place_type' => $place_type, 'place_type_id' => $place_type_id, 'woe_id' => $woe_id, 'place_id' => $place_id, 'threshold' => $threshold, 'contacts' => $contacts, 'min_upload_date' => $min_upload_date, 'max_upload_date' => $max_upload_date, 'min_taken_date' => $min_taken_date, 'max_taken_date' => $max_taken_date)); |
---|
1486 | } |
---|
1487 | |
---|
1488 | function places_placesForTags ($place_type_id, $woe_id = NULL, $place_id = NULL, $threshold = NULL, $tags = NULL, $tag_mode = NULL, $machine_tags = NULL, $machine_tag_mode = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) { |
---|
1489 | /* https://www.flickr.com/services/api/flickr.places.placesForTags.html */ |
---|
1490 | return $this->call('flickr.places.placesForTags', array('place_type_id' => $place_type_id, 'woe_id' => $woe_id, 'place_id' => $place_id, 'threshold' => $threshold, 'tags' => $tags, 'tag_mode' => $tag_mode, 'machine_tags' => $machine_tags, 'machine_tag_mode' => $machine_tag_mode, 'min_upload_date' => $min_upload_date, 'max_upload_date' => $max_upload_date, 'min_taken_date' => $min_taken_date, 'max_taken_date' => $max_taken_date)); |
---|
1491 | } |
---|
1492 | |
---|
1493 | function places_placesForUser ($place_type_id = NULL, $place_type = NULL, $woe_id = NULL, $place_id = NULL, $threshold = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) { |
---|
1494 | /* https://www.flickr.com/services/api/flickr.places.placesForUser.html */ |
---|
1495 | return $this->call('flickr.places.placesForUser', array('place_type_id' => $place_type_id, 'place_type' => $place_type, 'woe_id' => $woe_id, 'place_id' => $place_id, 'threshold' => $threshold, 'min_upload_date' => $min_upload_date, 'max_upload_date' => $max_upload_date, 'min_taken_date' => $min_taken_date, 'max_taken_date' => $max_taken_date)); |
---|
1496 | } |
---|
1497 | |
---|
1498 | function places_resolvePlaceId ($place_id) { |
---|
1499 | /* https://www.flickr.com/services/api/flickr.places.resolvePlaceId.html */ |
---|
1500 | $rsp = $this->call('flickr.places.resolvePlaceId', array('place_id' => $place_id)); |
---|
1501 | return $rsp ? $rsp['location'] : $rsp; |
---|
1502 | } |
---|
1503 | |
---|
1504 | function places_resolvePlaceURL ($url) { |
---|
1505 | /* https://www.flickr.com/services/api/flickr.places.resolvePlaceURL.html */ |
---|
1506 | $rsp = $this->call('flickr.places.resolvePlaceURL', array('url' => $url)); |
---|
1507 | return $rsp ? $rsp['location'] : $rsp; |
---|
1508 | } |
---|
1509 | |
---|
1510 | function places_tagsForPlace ($woe_id = NULL, $place_id = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) { |
---|
1511 | /* https://www.flickr.com/services/api/flickr.places.tagsForPlace.html */ |
---|
1512 | return $this->call('flickr.places.tagsForPlace', array('woe_id' => $woe_id, 'place_id' => $place_id, 'min_upload_date' => $min_upload_date, 'max_upload_date' => $max_upload_date, 'min_taken_date' => $min_taken_date, 'max_taken_date' => $max_taken_date)); |
---|
1513 | } |
---|
1514 | |
---|
1515 | /* Prefs Methods */ |
---|
1516 | function prefs_getContentType () { |
---|
1517 | /* https://www.flickr.com/services/api/flickr.prefs.getContentType.html */ |
---|
1518 | $rsp = $this->call('flickr.prefs.getContentType', array()); |
---|
1519 | return $rsp ? $rsp['person'] : $rsp; |
---|
1520 | } |
---|
1521 | |
---|
1522 | function prefs_getGeoPerms () { |
---|
1523 | /* https://www.flickr.com/services/api/flickr.prefs.getGeoPerms.html */ |
---|
1524 | return $this->call('flickr.prefs.getGeoPerms', array()); |
---|
1525 | } |
---|
1526 | |
---|
1527 | function prefs_getHidden () { |
---|
1528 | /* https://www.flickr.com/services/api/flickr.prefs.getHidden.html */ |
---|
1529 | $rsp = $this->call('flickr.prefs.getHidden', array()); |
---|
1530 | return $rsp ? $rsp['person'] : $rsp; |
---|
1531 | } |
---|
1532 | |
---|
1533 | function prefs_getPrivacy () { |
---|
1534 | /* https://www.flickr.com/services/api/flickr.prefs.getPrivacy.html */ |
---|
1535 | $rsp = $this->call('flickr.prefs.getPrivacy', array()); |
---|
1536 | return $rsp ? $rsp['person'] : $rsp; |
---|
1537 | } |
---|
1538 | |
---|
1539 | function prefs_getSafetyLevel () { |
---|
1540 | /* https://www.flickr.com/services/api/flickr.prefs.getSafetyLevel.html */ |
---|
1541 | $rsp = $this->call('flickr.prefs.getSafetyLevel', array()); |
---|
1542 | return $rsp ? $rsp['person'] : $rsp; |
---|
1543 | } |
---|
1544 | |
---|
1545 | /* Reflection Methods */ |
---|
1546 | function reflection_getMethodInfo ($method_name) { |
---|
1547 | /* https://www.flickr.com/services/api/flickr.reflection.getMethodInfo.html */ |
---|
1548 | $this->request("flickr.reflection.getMethodInfo", array("method_name" => $method_name)); |
---|
1549 | return $this->parsed_response ? $this->parsed_response : false; |
---|
1550 | } |
---|
1551 | |
---|
1552 | function reflection_getMethods () { |
---|
1553 | /* https://www.flickr.com/services/api/flickr.reflection.getMethods.html */ |
---|
1554 | $this->request("flickr.reflection.getMethods"); |
---|
1555 | return $this->parsed_response ? $this->parsed_response['methods']['method'] : false; |
---|
1556 | } |
---|
1557 | |
---|
1558 | /* Stats Methods */ |
---|
1559 | function stats_getCollectionDomains ($date, $collection_id = NULL, $per_page = NULL, $page = NULL) { |
---|
1560 | /* https://www.flickr.com/services/api/flickr.stats.getCollectionDomains.html */ |
---|
1561 | return $this->call('flickr.stats.getCollectionDomains', array('date' => $date, 'collection_id' => $collection_id, 'per_page' => $per_page, 'page' => $page)); |
---|
1562 | } |
---|
1563 | |
---|
1564 | function stats_getCollectionReferrers ($date, $domain, $collection_id = NULL, $per_page = NULL, $page = NULL) { |
---|
1565 | /* https://www.flickr.com/services/api/flickr.stats.getCollectionReferrers.html */ |
---|
1566 | return $this->call('flickr.stats.getCollectionReferrers', array('date' => $date, 'domain' => $domain, 'collection_id' => $collection_id, 'per_page' => $per_page, 'page' => $page)); |
---|
1567 | } |
---|
1568 | |
---|
1569 | function stats_getCollectionStats ($date, $collection_id) { |
---|
1570 | /* https://www.flickr.com/services/api/flickr.stats.getCollectionStats.html */ |
---|
1571 | return $this->call('flickr.stats.getCollectionStats', array('date' => $date, 'collection_id' => $collection_id)); |
---|
1572 | } |
---|
1573 | |
---|
1574 | function stats_getCSVFiles () { |
---|
1575 | /* https://www.flickr.com/services/api/flickr.stats.getCSVFiles.html */ |
---|
1576 | return $this->call('flickr.stats.getCSVFiles', array()); |
---|
1577 | } |
---|
1578 | |
---|
1579 | function stats_getPhotoDomains ($date, $photo_id = NULL, $per_page = NULL, $page = NULL) { |
---|
1580 | /* https://www.flickr.com/services/api/flickr.stats.getPhotoDomains.html */ |
---|
1581 | return $this->call('flickr.stats.getPhotoDomains', array('date' => $date, 'photo_id' => $photo_id, 'per_page' => $per_page, 'page' => $page)); |
---|
1582 | } |
---|
1583 | |
---|
1584 | function stats_getPhotoReferrers ($date, $domain, $photo_id = NULL, $per_page = NULL, $page = NULL) { |
---|
1585 | /* https://www.flickr.com/services/api/flickr.stats.getPhotoReferrers.html */ |
---|
1586 | return $this->call('flickr.stats.getPhotoReferrers', array('date' => $date, 'domain' => $domain, 'photo_id' => $photo_id, 'per_page' => $per_page, 'page' => $page)); |
---|
1587 | } |
---|
1588 | |
---|
1589 | function stats_getPhotosetDomains ($date, $photoset_id = NULL, $per_page = NULL, $page = NULL) { |
---|
1590 | /* https://www.flickr.com/services/api/flickr.stats.getPhotosetDomains.html */ |
---|
1591 | return $this->call('flickr.stats.getPhotosetDomains', array('date' => $date, 'photoset_id' => $photoset_id, 'per_page' => $per_page, 'page' => $page)); |
---|
1592 | } |
---|
1593 | |
---|
1594 | function stats_getPhotosetReferrers ($date, $domain, $photoset_id = NULL, $per_page = NULL, $page = NULL) { |
---|
1595 | /* https://www.flickr.com/services/api/flickr.stats.getPhotosetReferrers.html */ |
---|
1596 | return $this->call('flickr.stats.getPhotosetReferrers', array('date' => $date, 'domain' => $domain, 'photoset_id' => $photoset_id, 'per_page' => $per_page, 'page' => $page)); |
---|
1597 | } |
---|
1598 | |
---|
1599 | function stats_getPhotosetStats ($date, $photoset_id) { |
---|
1600 | /* https://www.flickr.com/services/api/flickr.stats.getPhotosetStats.html */ |
---|
1601 | return $this->call('flickr.stats.getPhotosetStats', array('date' => $date, 'photoset_id' => $photoset_id)); |
---|
1602 | } |
---|
1603 | |
---|
1604 | function stats_getPhotoStats ($date, $photo_id) { |
---|
1605 | /* https://www.flickr.com/services/api/flickr.stats.getPhotoStats.html */ |
---|
1606 | return $this->call('flickr.stats.getPhotoStats', array('date' => $date, 'photo_id' => $photo_id)); |
---|
1607 | } |
---|
1608 | |
---|
1609 | function stats_getPhotostreamDomains ($date, $per_page = NULL, $page = NULL) { |
---|
1610 | /* https://www.flickr.com/services/api/flickr.stats.getPhotostreamDomains.html */ |
---|
1611 | return $this->call('flickr.stats.getPhotostreamDomains', array('date' => $date, 'per_page' => $per_page, 'page' => $page)); |
---|
1612 | } |
---|
1613 | |
---|
1614 | function stats_getPhotostreamReferrers ($date, $domain, $per_page = NULL, $page = NULL) { |
---|
1615 | /* https://www.flickr.com/services/api/flickr.stats.getPhotostreamReferrers.html */ |
---|
1616 | return $this->call('flickr.stats.getPhotostreamReferrers', array('date' => $date, 'domain' => $domain, 'per_page' => $per_page, 'page' => $page)); |
---|
1617 | } |
---|
1618 | |
---|
1619 | function stats_getPhotostreamStats ($date) { |
---|
1620 | /* https://www.flickr.com/services/api/flickr.stats.getPhotostreamStats.html */ |
---|
1621 | return $this->call('flickr.stats.getPhotostreamStats', array('date' => $date)); |
---|
1622 | } |
---|
1623 | |
---|
1624 | function stats_getPopularPhotos ($date = NULL, $sort = NULL, $per_page = NULL, $page = NULL) { |
---|
1625 | /* https://www.flickr.com/services/api/flickr.stats.getPopularPhotos.html */ |
---|
1626 | return $this->call('flickr.stats.getPopularPhotos', array('date' => $date, 'sort' => $sort, 'per_page' => $per_page, 'page' => $page)); |
---|
1627 | } |
---|
1628 | |
---|
1629 | function stats_getTotalViews ($date = NULL) { |
---|
1630 | /* https://www.flickr.com/services/api/flickr.stats.getTotalViews.html */ |
---|
1631 | return $this->call('flickr.stats.getTotalViews', array('date' => $date)); |
---|
1632 | } |
---|
1633 | |
---|
1634 | /* Tags Methods */ |
---|
1635 | function tags_getClusterPhotos ($tag, $cluster_id) { |
---|
1636 | /* https://www.flickr.com/services/api/flickr.tags.getClusterPhotos.html */ |
---|
1637 | return $this->call('flickr.tags.getClusterPhotos', array('tag' => $tag, 'cluster_id' => $cluster_id)); |
---|
1638 | } |
---|
1639 | |
---|
1640 | function tags_getClusters ($tag) { |
---|
1641 | /* https://www.flickr.com/services/api/flickr.tags.getClusters.html */ |
---|
1642 | return $this->call('flickr.tags.getClusters', array('tag' => $tag)); |
---|
1643 | } |
---|
1644 | |
---|
1645 | function tags_getHotList ($period = NULL, $count = NULL) { |
---|
1646 | /* https://www.flickr.com/services/api/flickr.tags.getHotList.html */ |
---|
1647 | $this->request("flickr.tags.getHotList", array("period" => $period, "count" => $count)); |
---|
1648 | return $this->parsed_response ? $this->parsed_response['hottags'] : false; |
---|
1649 | } |
---|
1650 | |
---|
1651 | function tags_getListPhoto ($photo_id) { |
---|
1652 | /* https://www.flickr.com/services/api/flickr.tags.getListPhoto.html */ |
---|
1653 | $this->request("flickr.tags.getListPhoto", array("photo_id" => $photo_id)); |
---|
1654 | return $this->parsed_response ? $this->parsed_response['photo']['tags']['tag'] : false; |
---|
1655 | } |
---|
1656 | |
---|
1657 | function tags_getListUser ($user_id = NULL) { |
---|
1658 | /* https://www.flickr.com/services/api/flickr.tags.getListUser.html */ |
---|
1659 | $this->request("flickr.tags.getListUser", array("user_id" => $user_id)); |
---|
1660 | return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false; |
---|
1661 | } |
---|
1662 | |
---|
1663 | function tags_getListUserPopular ($user_id = NULL, $count = NULL) { |
---|
1664 | /* https://www.flickr.com/services/api/flickr.tags.getListUserPopular.html */ |
---|
1665 | $this->request("flickr.tags.getListUserPopular", array("user_id" => $user_id, "count" => $count)); |
---|
1666 | return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false; |
---|
1667 | } |
---|
1668 | |
---|
1669 | function tags_getListUserRaw ($tag = NULL) { |
---|
1670 | /* https://www.flickr.com/services/api/flickr.tags.getListUserRaw.html */ |
---|
1671 | return $this->call('flickr.tags.getListUserRaw', array('tag' => $tag)); |
---|
1672 | } |
---|
1673 | |
---|
1674 | function tags_getRelated ($tag) { |
---|
1675 | /* https://www.flickr.com/services/api/flickr.tags.getRelated.html */ |
---|
1676 | $this->request("flickr.tags.getRelated", array("tag" => $tag)); |
---|
1677 | return $this->parsed_response ? $this->parsed_response['tags'] : false; |
---|
1678 | } |
---|
1679 | |
---|
1680 | function test_echo ($args = array()) { |
---|
1681 | /* https://www.flickr.com/services/api/flickr.test.echo.html */ |
---|
1682 | $this->request("flickr.test.echo", $args); |
---|
1683 | return $this->parsed_response ? $this->parsed_response : false; |
---|
1684 | } |
---|
1685 | |
---|
1686 | function test_login () { |
---|
1687 | /* https://www.flickr.com/services/api/flickr.test.login.html */ |
---|
1688 | $this->request("flickr.test.login"); |
---|
1689 | return $this->parsed_response ? $this->parsed_response['user'] : false; |
---|
1690 | } |
---|
1691 | |
---|
1692 | function urls_getGroup ($group_id) { |
---|
1693 | /* https://www.flickr.com/services/api/flickr.urls.getGroup.html */ |
---|
1694 | $this->request("flickr.urls.getGroup", array("group_id"=>$group_id)); |
---|
1695 | return $this->parsed_response ? $this->parsed_response['group']['url'] : false; |
---|
1696 | } |
---|
1697 | |
---|
1698 | function urls_getUserPhotos ($user_id = NULL) { |
---|
1699 | /* https://www.flickr.com/services/api/flickr.urls.getUserPhotos.html */ |
---|
1700 | $this->request("flickr.urls.getUserPhotos", array("user_id"=>$user_id)); |
---|
1701 | return $this->parsed_response ? $this->parsed_response['user']['url'] : false; |
---|
1702 | } |
---|
1703 | |
---|
1704 | function urls_getUserProfile ($user_id = NULL) { |
---|
1705 | /* https://www.flickr.com/services/api/flickr.urls.getUserProfile.html */ |
---|
1706 | $this->request("flickr.urls.getUserProfile", array("user_id"=>$user_id)); |
---|
1707 | return $this->parsed_response ? $this->parsed_response['user']['url'] : false; |
---|
1708 | } |
---|
1709 | |
---|
1710 | function urls_lookupGallery ($url) { |
---|
1711 | /* https://www.flickr.com/services/api/flickr.urls.lookupGallery.html */ |
---|
1712 | return $this->call('flickr.urls.lookupGallery', array('url' => $url)); |
---|
1713 | } |
---|
1714 | |
---|
1715 | function urls_lookupGroup ($url) { |
---|
1716 | /* https://www.flickr.com/services/api/flickr.urls.lookupGroup.html */ |
---|
1717 | $this->request("flickr.urls.lookupGroup", array("url"=>$url)); |
---|
1718 | return $this->parsed_response ? $this->parsed_response['group'] : false; |
---|
1719 | } |
---|
1720 | |
---|
1721 | function urls_lookupUser ($url) { |
---|
1722 | /* https://www.flickr.com/services/api/flickr.photos.notes.edit.html */ |
---|
1723 | $this->request("flickr.urls.lookupUser", array("url"=>$url)); |
---|
1724 | return $this->parsed_response ? $this->parsed_response['user'] : false; |
---|
1725 | } |
---|
1726 | } |
---|
1727 | } |
---|
1728 | |
---|
1729 | if ( !class_exists('phpFlickr_pager') ) { |
---|
1730 | class phpFlickr_pager { |
---|
1731 | var $phpFlickr, $per_page, $method, $args, $results, $global_phpFlickr; |
---|
1732 | var $total = null, $page = 0, $pages = null, $photos, $_extra = null; |
---|
1733 | |
---|
1734 | |
---|
1735 | function phpFlickr_pager($phpFlickr, $method = null, $args = null, $per_page = 30) { |
---|
1736 | $this->per_page = $per_page; |
---|
1737 | $this->method = $method; |
---|
1738 | $this->args = $args; |
---|
1739 | $this->set_phpFlickr($phpFlickr); |
---|
1740 | } |
---|
1741 | |
---|
1742 | function set_phpFlickr($phpFlickr) { |
---|
1743 | if ( is_a($phpFlickr, 'phpFlickr') ) { |
---|
1744 | $this->phpFlickr = $phpFlickr; |
---|
1745 | if ( $this->phpFlickr->cache ) { |
---|
1746 | $this->args['per_page'] = 500; |
---|
1747 | } else { |
---|
1748 | $this->args['per_page'] = (int) $this->per_page; |
---|
1749 | } |
---|
1750 | } |
---|
1751 | } |
---|
1752 | |
---|
1753 | function __sleep() { |
---|
1754 | return array( |
---|
1755 | 'method', |
---|
1756 | 'args', |
---|
1757 | 'per_page', |
---|
1758 | 'page', |
---|
1759 | '_extra', |
---|
1760 | ); |
---|
1761 | } |
---|
1762 | |
---|
1763 | function load($page) { |
---|
1764 | $allowed_methods = array( |
---|
1765 | 'flickr.photos.search' => 'photos', |
---|
1766 | 'flickr.photosets.getPhotos' => 'photoset', |
---|
1767 | ); |
---|
1768 | if ( !in_array($this->method, array_keys($allowed_methods)) ) return false; |
---|
1769 | |
---|
1770 | if ( $this->phpFlickr->cache ) { |
---|
1771 | $min = ($page - 1) * $this->per_page; |
---|
1772 | $max = $page * $this->per_page - 1; |
---|
1773 | if ( floor($min/500) == floor($max/500) ) { |
---|
1774 | $this->args['page'] = floor($min/500) + 1; |
---|
1775 | $this->results = $this->phpFlickr->call($this->method, $this->args); |
---|
1776 | if ( $this->results ) { |
---|
1777 | $this->results = $this->results[$allowed_methods[$this->method]]; |
---|
1778 | $this->photos = array_slice($this->results['photo'], $min % 500, $this->per_page); |
---|
1779 | $this->total = $this->results['total']; |
---|
1780 | $this->pages = ceil($this->results['total'] / $this->per_page); |
---|
1781 | return true; |
---|
1782 | } else { |
---|
1783 | return false; |
---|
1784 | } |
---|
1785 | } else { |
---|
1786 | $this->args['page'] = floor($min/500) + 1; |
---|
1787 | $this->results = $this->phpFlickr->call($this->method, $this->args); |
---|
1788 | if ( $this->results ) { |
---|
1789 | $this->results = $this->results[$allowed_methods[$this->method]]; |
---|
1790 | |
---|
1791 | $this->photos = array_slice($this->results['photo'], $min % 500); |
---|
1792 | $this->total = $this->results['total']; |
---|
1793 | $this->pages = ceil($this->results['total'] / $this->per_page); |
---|
1794 | |
---|
1795 | $this->args['page'] = floor($min/500) + 2; |
---|
1796 | $this->results = $this->phpFlickr->call($this->method, $this->args); |
---|
1797 | if ( $this->results ) { |
---|
1798 | $this->results = $this->results[$allowed_methods[$this->method]]; |
---|
1799 | $this->photos = array_merge($this->photos, array_slice($this->results['photo'], 0, $max % 500 + 1)); |
---|
1800 | } |
---|
1801 | return true; |
---|
1802 | } else { |
---|
1803 | return false; |
---|
1804 | } |
---|
1805 | |
---|
1806 | } |
---|
1807 | } else { |
---|
1808 | $this->args['page'] = $page; |
---|
1809 | $this->results = $this->phpFlickr->call($this->method, $this->args); |
---|
1810 | if ( $this->results ) { |
---|
1811 | $this->results = $this->results[$allowed_methods[$this->method]]; |
---|
1812 | |
---|
1813 | $this->photos = $this->results['photo']; |
---|
1814 | $this->total = $this->results['total']; |
---|
1815 | $this->pages = $this->results['pages']; |
---|
1816 | return true; |
---|
1817 | } else { |
---|
1818 | return false; |
---|
1819 | } |
---|
1820 | } |
---|
1821 | } |
---|
1822 | |
---|
1823 | function get($page = null) { |
---|
1824 | if ( is_null($page) ) { |
---|
1825 | $page = $this->page; |
---|
1826 | } else { |
---|
1827 | $this->page = $page; |
---|
1828 | } |
---|
1829 | if ( $this->load($page) ) { |
---|
1830 | return $this->photos; |
---|
1831 | } |
---|
1832 | $this->total = 0; |
---|
1833 | $this->pages = 0; |
---|
1834 | return array(); |
---|
1835 | } |
---|
1836 | |
---|
1837 | function next() { |
---|
1838 | $this->page++; |
---|
1839 | if ( $this->load($this->page) ) { |
---|
1840 | return $this->photos; |
---|
1841 | } |
---|
1842 | $this->total = 0; |
---|
1843 | $this->pages = 0; |
---|
1844 | return array(); |
---|
1845 | } |
---|
1846 | |
---|
1847 | } |
---|
1848 | } |
---|
1849 | |
---|
1850 | ?> |
---|