source: extensions/flickr2piwigo/include/phpFlickr/phpFlickr.php @ 16063

Last change on this file since 16063 was 16063, checked in by mistic100, 12 years ago

initial version

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