dmahr

Flickr-Gallery revised phpFlickr.php

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