Dotclear

source: plugins/wflickr/phpFlickr.php @ 766

Revision 766, 59.6 KB checked in by xave, 15 years ago (diff)

New plugins: dcFlickr & wflickr (by Suricat)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision
  • Property svn:mime-type set to text/plain
Line 
1<?php
2/* phpFlickr Class 2.1.0
3 * Written by Dan Coulter (dan@dancoulter.com)
4 * Sourceforge Project Page: http://www.sourceforge.net/projects/phpflickr/
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/ or http://phpflickr.sourceforge.net
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 project page:
14 *         http://sourceforge.net/forum/forum.php?forum_id=469652
15 *
16 */
17if (session_id() == "") {
18    @session_start();
19}
20
21// Decides which include path delimiter to use.  Windows should be using a semi-colon
22// and everything else should be using a colon.  If this isn't working on your system,
23// comment out this if statement and manually set the correct value into $path_delimiter.
24if (strpos(__FILE__, ':') !== false) {
25    $path_delimiter = ';';
26} else {
27    $path_delimiter = ':';
28}
29
30// This will add the packaged PEAR files into the include path for PHP, allowing you
31// to use them transparently.  This will prefer officially installed PEAR files if you
32// have them.  If you want to prefer the packaged files (there shouldn't be any reason
33// to), swap the two elements around the $path_delimiter variable.  If you don't have
34// the PEAR packages installed, you can leave this like it is and move on.
35
36ini_set('include_path', ini_get('include_path') . $path_delimiter . dirname(__FILE__) . '/PEAR');
37
38// If you have problems including the default PEAR install (like if your open_basedir
39// setting doesn't allow you to include files outside of your web root), comment out
40// the line above and uncomment the next line:
41
42// ini_set('include_path', dirname(__FILE__) . '/PEAR' . $path_delimiter . ini_get('include_path'));
43
44class phpFlickr {
45    var $api_key;
46    var $secret;
47    var $REST = 'http://api.flickr.com/services/rest/';
48    var $Upload = 'http://api.flickr.com/services/upload/';
49    var $Replace = 'http://api.flickr.com/services/replace/';
50    var $req;
51    var $response;
52    var $parsed_response;
53    var $cache = false;
54    var $cache_db = null;
55    var $cache_table = null;
56    var $cache_dir = null;
57    var $cache_expire = null;
58    var $die_on_error;
59    var $error_code;
60    Var $error_msg;
61    var $token;
62    var $php_version;
63
64    /*
65     * When your database cache table hits this many rows, a cleanup
66     * will occur to get rid of all of the old rows and cleanup the
67     * garbage in the table.  For most personal apps, 1000 rows should
68     * be more than enough.  If your site gets hit by a lot of traffic
69     * or you have a lot of disk space to spare, bump this number up.
70     * You should try to set it high enough that the cleanup only
71     * happens every once in a while, so this will depend on the growth
72     * of your table.
73     */
74    var $max_cache_rows = 1000;
75
76    function phpFlickr ($api_key, $secret = NULL, $die_on_error = false)
77    {
78        //The API Key must be set before any calls can be made.  You can
79        //get your own at http://www.flickr.com/services/api/misc.api_keys.html
80        $this->api_key = $api_key;
81        $this->secret = $secret;
82        $this->die_on_error = $die_on_error;
83        $this->service = "flickr";
84
85        //Find the PHP version and store it for future reference
86        $this->php_version = explode("-", phpversion());
87        $this->php_version = explode(".", $this->php_version[0]);
88
89        //All calls to the API are done via the POST method using the PEAR::HTTP_Request package.
90        require_once 'HTTP/Request.php';
91        $this->req =& new HTTP_Request();
92        $this->req->setMethod(HTTP_REQUEST_METHOD_POST);
93    }
94
95    function enableCache($type, $connection, $cache_expire = 600, $table = 'flickr_cache')
96    {
97        // Turns on caching.  $type must be either "db" (for database caching) or "fs" (for filesystem).
98        // When using db, $connection must be a PEAR::DB connection string. Example:
99        //      "mysql://user:password@server/database"
100        // If the $table, doesn't exist, it will attempt to create it.
101        // When using file system, caching, the $connection is the folder that the web server has write
102        // access to. Use absolute paths for best results.  Relative paths may have unexpected behavior
103        // when you include this.  They'll usually work, you'll just want to test them.
104        if ($type == 'db') {
105            require_once 'DB.php';
106            $db =& DB::connect($connection);
107            if (PEAR::isError($db)) {
108                die($db->getMessage());
109            }
110
111            /*
112             * If high performance is crucial, you can easily comment
113             * out this query once you've created your database table.
114             */
115
116            $db->query("
117                CREATE TABLE IF NOT EXISTS `$table` (
118                    `request` CHAR( 35 ) NOT NULL ,
119                    `response` MEDIUMTEXT NOT NULL ,
120                    `expiration` DATETIME NOT NULL ,
121                    INDEX ( `request` )
122                ) TYPE = MYISAM");
123
124            if ($db->getOne("SELECT COUNT(*) FROM $table") > $this->max_cache_rows) {
125                $db->query("DELETE FROM $table WHERE expiration < DATE_SUB(NOW(), INTERVAL $cache_expire second)");
126                $db->query('OPTIMIZE TABLE ' . $this->cache_table);
127            }
128
129            $this->cache = 'db';
130            $this->cache_db = $db;
131            $this->cache_table = $table;
132        } elseif ($type == 'fs') {
133            $this->cache = 'fs';
134            $connection = realpath($connection);
135            $this->cache_dir = $connection;
136            if ($dir = opendir($this->cache_dir)) {
137                while ($file = readdir($dir)) {
138                    if (substr($file, -6) == '.cache' && ((filemtime($this->cache_dir . '/' . $file) + $cache_expire) < time()) ) {
139                        unlink($this->cache_dir . '/' . $file);
140                    }
141                }
142            }
143        }
144        $this->cache_expire = $cache_expire;
145    }
146
147    function getCached ($request)
148    {
149        //Checks the database or filesystem for a cached result to the request.
150        //If there is no cache result, it returns a value of false. If it finds one,
151        //it returns the unparsed XML.
152        $reqhash = md5(serialize($request));
153        if ($this->cache == 'db') {
154            $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);
155            if (!empty($result)) {
156                return $result;
157            }
158        } elseif ($this->cache == 'fs') {
159            $file = $this->cache_dir . '/' . $reqhash . '.cache';
160            if (file_exists($file)) {
161                    if ($this->php_version[0] > 4 || ($this->php_version[0] == 4 && $this->php_version[1] >= 3)) {
162                         return file_get_contents($file);
163                    } else {
164                         return implode('', file($file));
165                    }
166            }
167        }
168        return false;
169    }
170
171    function cache ($request, $response)
172    {
173        //Caches the unparsed XML of a request.
174        $reqhash = md5(serialize($request));
175        if ($this->cache == 'db') {
176            //$this->cache_db->query("DELETE FROM $this->cache_table WHERE request = '$reqhash'");
177            if ($this->cache_db->getOne("SELECT COUNT(*) FROM {$this->cache_table} WHERE request = '$reqhash'")) {
178                $sql = "UPDATE " . $this->cache_table . " SET response = ?, expiration = ? WHERE request = ?";
179                $this->cache_db->query($sql, array($response, strftime("%Y-%m-%d %H:%M:%S"), $reqhash));
180            } else {
181                $sql = "INSERT INTO " . $this->cache_table . " (request, response, expiration) VALUES ('$reqhash', '" . str_replace("'", "''", $response) . "', '" . strftime("%Y-%m-%d %H:%M:%S") . "')";
182                $this->cache_db->query($sql);
183            }
184        } elseif ($this->cache == "fs") {
185            $file = $this->cache_dir . "/" . $reqhash . ".cache";
186            $fstream = fopen($file, "w");
187            $result = fwrite($fstream,$response);
188            fclose($fstream);
189            return $result;
190        }
191        return false;
192    }
193
194    function request ($command, $args = array(), $nocache = false)
195    {
196        //Sends a request to Flickr's REST endpoint via POST.
197        $this->req->setURL($this->REST);
198        $this->req->clearPostData();
199        if (substr($command,0,7) != "flickr.") {
200            $command = "flickr." . $command;
201        }
202
203        //Process arguments, including method and login data.
204        $args = array_merge(array("method" => $command, "format" => "php_serial", "api_key" => $this->api_key), $args);
205        if (!empty($this->token)) {
206            $args = array_merge($args, array("auth_token" => $this->token));
207        } elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
208            $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token']));
209        }
210        ksort($args);
211        $auth_sig = "";
212        if (!($this->response = $this->getCached($args)) || $nocache) {
213            foreach ($args as $key => $data) {
214                $auth_sig .= $key . $data;
215                $this->req->addPostData($key, $data);
216            }
217            if (!empty($this->secret)) {
218                $api_sig = md5($this->secret . $auth_sig);
219                $this->req->addPostData("api_sig", $api_sig);
220            }
221
222            //Send Requests
223            if ($this->req->sendRequest()) {
224                $this->response = $this->req->getResponseBody();
225                $this->cache($args, $this->response);
226            } else {
227                die("There has been a problem sending your command to the server.");
228            }
229        }
230        /*
231         * Uncomment this line (and comment out the next one) if you're doing large queries
232         * and you're concerned about time.  This will, however, change the structure of
233         * the result, so be sure that you look at the results.
234         */
235        //$this->parsed_response = unserialize($this->response);
236        $this->parsed_response = $this->clean_text_nodes(unserialize($this->response));
237        if ($this->parsed_response['stat'] == 'fail') {
238            if ($this->die_on_error) die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
239            else {
240                $this->error_code = $this->parsed_response['code'];
241                $this->error_msg = $this->parsed_response['message'];
242                $this->parsed_response = false;
243            }
244        } else {
245            $this->error_code = false;
246            $this->error_msg = false;
247        }
248        return $this->response;
249    }
250
251    function clean_text_nodes($arr) {
252        if (!is_array($arr)) {
253            return $arr;
254        } elseif (count($arr) == 0) {
255            return $arr;
256        } elseif (count($arr) == 1 && array_key_exists('_content', $arr)) {
257            return $arr['_content'];
258        } else {
259            foreach ($arr as $key => $element) {
260                $arr[$key] = $this->clean_text_nodes($element);
261            }
262            return($arr);
263        }
264    }
265
266    function setToken($token)
267    {
268        // Sets an authentication token to use instead of the session variable
269        $this->token = $token;
270    }
271
272    function setProxy($server, $port)
273    {
274        // Sets the proxy for all phpFlickr calls.
275        $this->req->setProxy($server, $port);
276    }
277
278    function getErrorCode()
279    {
280          // Returns the error code of the last call.  If the last call did not
281          // return an error. This will return a false boolean.
282          return $this->error_code;
283    }
284
285    function getErrorMsg()
286    {
287          // Returns the error message of the last call.  If the last call did not
288          // return an error. This will return a false boolean.
289          return $this->error_msg;
290    }
291
292    /* These functions are front ends for the flickr calls */
293
294    function buildPhotoURL ($photo, $size = "Medium")
295    {
296        //receives an array (can use the individual photo data returned
297        //from an API call) and returns a URL (doesn't mean that the
298        //file size exists)
299        $sizes = array(
300            "square" => "_s",
301            "thumbnail" => "_t",
302            "small" => "_m",
303            "medium" => "",
304            "large" => "_b",
305            "original" => "_o"
306        );
307       
308        $size = strtolower($size);
309        if (!array_key_exists($size, $sizes)) {
310            $size = "medium";
311        }
312       
313        if ($size == "original") {
314            $url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['originalsecret'] . "_o" . "." . $photo['originalformat'];
315        } else {
316            $url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes[$size] . ".jpg";
317        }
318        return $url;
319    }
320
321    function getFriendlyGeodata($lat, $lon) {
322        /* I've added this method to get the friendly geodata (i.e. 'in New York, NY') that the
323         * website provides, but isn't available in the API. I'm providing this service as long
324         * as it doesn't flood my server with requests and crash it all the time.
325         */
326        return unserialize(file_get_contents('http://phpflickr.com/geodata/?format=php&lat=' . $lat . '&lon=' . $lon));
327    }
328
329    function sync_upload ($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) {
330        $upload_req =& new HTTP_Request();
331        $upload_req->setMethod(HTTP_REQUEST_METHOD_POST);
332
333
334        $upload_req->setURL($this->Upload);
335        $upload_req->clearPostData();
336
337        //Process arguments, including method and login data.
338        $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);
339        if (!empty($this->email)) {
340            $args = array_merge($args, array("email" => $this->email));
341        }
342        if (!empty($this->password)) {
343            $args = array_merge($args, array("password" => $this->password));
344        }
345        if (!empty($this->token)) {
346            $args = array_merge($args, array("auth_token" => $this->token));
347        } elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
348            $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token']));
349        }
350
351        ksort($args);
352        $auth_sig = "";
353        foreach ($args as $key => $data) {
354            if ($data !== null) {
355                $auth_sig .= $key . $data;
356                $upload_req->addPostData($key, $data);
357            }
358        }
359        if (!empty($this->secret)) {
360            $api_sig = md5($this->secret . $auth_sig);
361            $upload_req->addPostData("api_sig", $api_sig);
362        }
363
364        $photo = realpath($photo);
365
366        $result = $upload_req->addFile("photo", $photo);
367
368        if (PEAR::isError($result)) {
369            die($result->getMessage());
370        }
371
372        //Send Requests
373        if ($upload_req->sendRequest()) {
374            $this->response = $upload_req->getResponseBody();
375        } else {
376            die("There has been a problem sending your command to the server.");
377        }
378
379        $rsp = explode("\n", $this->response);
380        foreach ($rsp as $line) {
381            if (ereg('<err code="([0-9]+)" msg="(.*)"', $line, $match)) {
382                if ($this->die_on_error)
383                    die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}");
384                else {
385                    $this->error_code = $match[1];
386                    $this->error_msg = $match[2];
387                    $this->parsed_response = false;
388                    return false;
389                }
390            } elseif (ereg("<photoid>(.*)</photoid>", $line, $match)) {
391                $this->error_code = false;
392                $this->error_msg = false;
393                return $match[1];
394            }
395        }
396    }
397
398    function async_upload ($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) {
399        $upload_req =& new HTTP_Request();
400        $upload_req->setMethod(HTTP_REQUEST_METHOD_POST);
401
402        $upload_req->setURL($this->Upload);
403        $upload_req->clearPostData();
404
405        //Process arguments, including method and login data.
406        $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);
407        if (!empty($this->email)) {
408            $args = array_merge($args, array("email" => $this->email));
409        }
410        if (!empty($this->password)) {
411            $args = array_merge($args, array("password" => $this->password));
412        }
413        if (!empty($this->token)) {
414            $args = array_merge($args, array("auth_token" => $this->token));
415        } elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
416            $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token']));
417        }
418
419        ksort($args);
420        $auth_sig = "";
421        foreach ($args as $key => $data) {
422            if ($data !== null) {
423                $auth_sig .= $key . $data;
424                $upload_req->addPostData($key, $data);
425            }
426        }
427        if (!empty($this->secret)) {
428            $api_sig = md5($this->secret . $auth_sig);
429            $upload_req->addPostData("api_sig", $api_sig);
430        }
431
432        $photo = realpath($photo);
433
434        $result = $upload_req->addFile("photo", $photo);
435
436        if (PEAR::isError($result)) {
437            die($result->getMessage());
438        }
439
440        //Send Requests
441        if ($upload_req->sendRequest()) {
442            $this->response = $upload_req->getResponseBody();
443        } else {
444            die("There has been a problem sending your command to the server.");
445        }
446
447        $rsp = explode("\n", $this->response);
448        foreach ($rsp as $line) {
449            if (ereg('<err code="([0-9]+)" msg="(.*)"', $line, $match)) {
450                if ($this->die_on_error)
451                    die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}");
452                else {
453                    $this->error_code = $match[1];
454                    $this->error_msg = $match[2];
455                    $this->parsed_response = false;
456                    return false;
457                }
458            } elseif (ereg("<ticketid>(.*)</", $line, $match)) {
459                $this->error_code = false;
460                $this->error_msg = false;
461                return $match[1];
462            }
463        }
464    }
465
466    // Interface for new replace API method.
467    function replace ($photo, $photo_id, $async = null) {
468        $upload_req =& new HTTP_Request();
469        $upload_req->setMethod(HTTP_REQUEST_METHOD_POST);
470
471        $upload_req->setURL($this->Replace);
472        $upload_req->clearPostData();
473
474        //Process arguments, including method and login data.
475        $args = array("api_key" => $this->api_key, "photo_id" => $photo_id, "async" => $async);
476        if (!empty($this->email)) {
477            $args = array_merge($args, array("email" => $this->email));
478        }
479        if (!empty($this->password)) {
480            $args = array_merge($args, array("password" => $this->password));
481        }
482        if (!empty($this->token)) {
483            $args = array_merge($args, array("auth_token" => $this->token));
484        } elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
485            $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token']));
486        }
487
488        ksort($args);
489        $auth_sig = "";
490        foreach ($args as $key => $data) {
491            if ($data !== null) {
492                $auth_sig .= $key . $data;
493                $upload_req->addPostData($key, $data);
494            }
495        }
496        if (!empty($this->secret)) {
497            $api_sig = md5($this->secret . $auth_sig);
498            $upload_req->addPostData("api_sig", $api_sig);
499        }
500
501        $photo = realpath($photo);
502
503        $result = $upload_req->addFile("photo", $photo);
504
505        if (PEAR::isError($result)) {
506            die($result->getMessage());
507        }
508
509        //Send Requests
510        if ($upload_req->sendRequest()) {
511            $this->response = $upload_req->getResponseBody();
512        } else {
513            die("There has been a problem sending your command to the server.");
514        }
515        if ($async == 1)
516            $find = 'ticketid';
517         else
518            $find = 'photoid';
519
520        $rsp = explode("\n", $this->response);
521        foreach ($rsp as $line) {
522            if (ereg('<err code="([0-9]+)" msg="(.*)"', $line, $match)) {
523                if ($this->die_on_error)
524                    die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}");
525                else {
526                    $this->error_code = $match[1];
527                    $this->error_msg = $match[2];
528                    $this->parsed_response = false;
529                    return false;
530                }
531            } elseif (ereg("<" . $find . ">(.*)</", $line, $match)) {
532                $this->error_code = false;
533                $this->error_msg = false;
534                return $match[1];
535            }
536        }
537    }
538
539    function auth ($perms = "read", $remember_uri = true)
540    {
541        // Redirects to Flickr's authentication piece if there is no valid token.
542        // If remember_uri is set to false, the callback script (included) will
543        // redirect to its default page.
544
545        if (empty($_SESSION['phpFlickr_auth_token']) && empty($this->token)) {
546            if ($remember_uri) {
547                $redirect = $_SERVER['REQUEST_URI'];
548            }
549            $api_sig = md5($this->secret . "api_key" . $this->api_key . "extra" . $redirect . "perms" . $perms);
550               if ($this->service == "23") {
551                    header("Location: http://www.23hq.com/services/auth/?api_key=" . $this->api_key . "&extra=" . $redirect . "&perms=" . $perms . "&api_sig=". $api_sig);
552               } else {
553                    header("Location: http://www.flickr.com/services/auth/?api_key=" . $this->api_key . "&extra=" . $redirect . "&perms=" . $perms . "&api_sig=". $api_sig);
554               }
555            exit;
556        } else {
557            $tmp = $this->die_on_error;
558            $this->die_on_error = false;
559            $rsp = $this->auth_checkToken();
560            if ($this->error_code !== false) {
561                unset($_SESSION['phpFlickr_auth_token']);
562                $this->auth($perms, $remember_uri);
563            }
564            $this->die_on_error = $tmp;
565            return $rsp['perms'];
566        }
567    }
568
569    /*******************************
570
571    To use the phpFlickr::call method, pass a string containing the API method you want
572    to use and an associative array of arguments.  For example:
573        $result = $f->call("flickr.photos.comments.getList", array("photo_id"=>'34952612'));
574    This method will allow you to make calls to arbitrary methods that haven't been
575    implemented in phpFlickr yet.
576
577    *******************************/
578
579    function call($method, $arguments)
580    {
581        $this->request($method, $arguments);
582        return $this->parsed_response;
583    }
584
585    /*
586        These functions are the direct implementations of flickr calls.
587        For method documentation, including arguments, visit the address
588        included in a comment in the function.
589    */
590
591    /* Activity methods */
592    function activity_userComments ($per_page = NULL, $page = NULL)
593    {
594        /* http://www.flickr.com/services/api/flickr.activity.userComments.html */
595        $this->request('flickr.activity.userComments', array("per_page" => $per_page, "page" => $page));
596        return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
597    }
598
599    function activity_userPhotos ($timeframe = NULL, $per_page = NULL, $page = NULL)
600    {
601        /* http://www.flickr.com/services/api/flickr.activity.userPhotos.html */
602        $this->request('flickr.activity.userPhotos', array("timeframe" => $timeframe, "per_page" => $per_page, "page" => $page));
603        return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
604    }
605
606    /* Authentication methods */
607    function auth_checkToken ()
608    {
609        /* http://www.flickr.com/services/api/flickr.auth.checkToken.html */
610        $this->request('flickr.auth.checkToken');
611        return $this->parsed_response ? $this->parsed_response['auth'] : false;
612    }
613
614    function auth_getFrob ()
615    {
616        /* http://www.flickr.com/services/api/flickr.auth.getFrob.html */
617        $this->request('flickr.auth.getFrob');
618        return $this->parsed_response ? $this->parsed_response['frob'] : false;
619    }
620
621    function auth_getFullToken ($mini_token)
622    {
623        /* http://www.flickr.com/services/api/flickr.auth.getFullToken.html */
624        $this->request('flickr.auth.getFullToken', array('mini_token'=>$mini_token));
625        return $this->parsed_response ? $this->parsed_response['auth'] : false;
626    }
627
628    function auth_getToken ($frob)
629    {
630        /* http://www.flickr.com/services/api/flickr.auth.getToken.html */
631        $this->request('flickr.auth.getToken', array('frob'=>$frob));
632        session_register('phpFlickr_auth_token');
633        $_SESSION['phpFlickr_auth_token'] = $this->parsed_response['auth']['token'];
634        return $this->parsed_response ? $this->parsed_response['auth'] : false;
635    }
636
637    /* Blogs methods */
638    function blogs_getList ()
639    {
640        /* http://www.flickr.com/services/api/flickr.blogs.getList.html */
641        $this->request('flickr.blogs.getList');
642        return $this->parsed_response ? $this->parsed_response['blogs']['blog'] : false;
643    }
644
645    function blogs_postPhoto($blog_id, $photo_id, $title, $description, $blog_password = NULL)
646    {
647        /* http://www.flickr.com/services/api/flickr.blogs.postPhoto.html */
648        $this->request('flickr.blogs.postPhoto', array('blog_id'=>$blog_id, 'photo_id'=>$photo_id, 'title'=>$title, 'description'=>$description, 'blog_password'=>$blog_password), TRUE);
649        return $this->parsed_response ? true : false;
650    }
651
652    /* Contacts Methods */
653    function contacts_getList ($filter = NULL, $page = NULL, $per_page = NULL)
654    {
655        /* http://www.flickr.com/services/api/flickr.contacts.getList.html */
656        $this->request('flickr.contacts.getList', array('filter'=>$filter, 'page'=>$page, 'per_page'=>$per_page));
657        return $this->parsed_response ? $this->parsed_response['contacts'] : false;
658    }
659
660    function contacts_getPublicList($user_id, $page = NULL, $per_page = NULL)
661    {
662        /* http://www.flickr.com/services/api/flickr.contacts.getPublicList.html */
663        $this->request('flickr.contacts.getPublicList', array('user_id'=>$user_id, 'page'=>$page, 'per_page'=>$per_page));
664        return $this->parsed_response ? $this->parsed_response['contacts'] : false;
665    }
666
667    /* Favorites Methods */
668    function favorites_add ($photo_id)
669    {
670        /* http://www.flickr.com/services/api/flickr.favorites.add.html */
671        $this->request('flickr.favorites.add', array('photo_id'=>$photo_id), TRUE);
672        return $this->parsed_response ? true : false;
673    }
674
675    function favorites_getList($user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
676    {
677        /* http://www.flickr.com/services/api/flickr.favorites.getList.html */
678        if (is_array($extras)) { $extras = implode(",", $extras); }
679        $this->request("flickr.favorites.getList", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
680        return $this->parsed_response ? $this->parsed_response['photos'] : false;
681    }
682
683    function favorites_getPublicList($user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
684    {
685        /* http://www.flickr.com/services/api/flickr.favorites.getPublicList.html */
686        if (is_array($extras)) {
687            $extras = implode(",", $extras);
688        }
689        $this->request("flickr.favorites.getPublicList", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
690        return $this->parsed_response ? $this->parsed_response['photos'] : false;
691    }
692
693    function favorites_remove($photo_id)
694    {
695        /* http://www.flickr.com/services/api/flickr.favorites.remove.html */
696        $this->request("flickr.favorites.remove", array("photo_id"=>$photo_id), TRUE);
697        return $this->parsed_response ? true : false;
698    }
699
700    /* Groups Methods */
701    function groups_browse ($cat_id = NULL)
702    {
703        /* http://www.flickr.com/services/api/flickr.groups.browse.html */
704        $this->request("flickr.groups.browse", array("cat_id"=>$cat_id));
705        return $this->parsed_response ? $this->parsed_response['category'] : false;
706    }
707
708    function groups_getInfo ($group_id)
709    {
710        /* http://www.flickr.com/services/api/flickr.groups.getInfo.html */
711        $this->request("flickr.groups.getInfo", array("group_id"=>$group_id));
712        return $this->parsed_response ? $this->parsed_response['group'] : false;
713    }
714
715     function groups_search ($text, $per_page=NULL, $page=NULL)
716     {
717          /* http://www.flickr.com/services/api/flickr.groups.search.html */
718          $this->request("flickr.groups.search", array("text"=>$text,"per_page"=>$per_page,"page"=>$page));
719        return $this->parsed_response ? $this->parsed_response['groups'] : false;
720     }
721
722    /* Groups Pools Methods */
723    function groups_pools_add ($photo_id, $group_id)
724    {
725        /* http://www.flickr.com/services/api/flickr.groups.pools.add.html */
726        $this->request("flickr.groups.pools.add", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
727        return $this->parsed_response ? true : false;
728    }
729
730    function groups_pools_getContext ($photo_id, $group_id)
731    {
732        /* http://www.flickr.com/services/api/flickr.groups.pools.getContext.html */
733        $this->request("flickr.groups.pools.getContext", array("photo_id"=>$photo_id, "group_id"=>$group_id));
734        return $this->parsed_response ? $this->parsed_response : false;
735    }
736
737    function groups_pools_getGroups ($page = NULL, $per_page = NULL)
738    {
739        /* http://www.flickr.com/services/api/flickr.groups.pools.getGroups.html */
740        $this->request("flickr.groups.pools.getGroups", array('page'=>$page, 'per_page'=>$per_page));
741        return $this->parsed_response ? $this->parsed_response['groups'] : false;
742    }
743
744    function groups_pools_getPhotos ($group_id, $tags = NULL, $user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
745    {
746          /* http://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html */
747        if (is_array($extras)) {
748            $extras = implode(",", $extras);
749        }
750        $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));
751        return $this->parsed_response ? $this->parsed_response['photos'] : false;
752    }
753
754    function groups_pools_remove ($photo_id, $group_id)
755    {
756        /* http://www.flickr.com/services/api/flickr.groups.pools.remove.html */
757        $this->request("flickr.groups.pools.remove", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
758        return $this->parsed_response ? true : false;
759    }
760
761    /* Interestingness methods */
762     function interestingness_getList($date = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
763     {
764        /* http://www.flickr.com/services/api/flickr.interestingness.getList.html */
765        if (is_array($extras)) {
766            $extras = implode(",", $extras);
767        }
768
769        $this->request("flickr.interestingness.getList", array("date"=>$date, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
770        return $this->parsed_response ? $this->parsed_response['photos'] : false;
771    }
772
773    /* People methods */
774    function people_findByEmail ($find_email)
775    {
776        /* http://www.flickr.com/services/api/flickr.people.findByEmail.html */
777        $this->request("flickr.people.findByEmail", array("find_email"=>$find_email));
778        return $this->parsed_response ? $this->parsed_response['user'] : false;
779    }
780
781    function people_findByUsername ($username)
782    {
783        /* http://www.flickr.com/services/api/flickr.people.findByUsername.html */
784        $this->request("flickr.people.findByUsername", array("username"=>$username));
785        return $this->parsed_response ? $this->parsed_response['user'] : false;
786    }
787
788    function people_getInfo($user_id)
789    {
790        /* http://www.flickr.com/services/api/flickr.people.getInfo.html */
791        $this->request("flickr.people.getInfo", array("user_id"=>$user_id));
792        return $this->parsed_response ? $this->parsed_response['person'] : false;
793    }
794
795    function people_getPublicGroups($user_id)
796    {
797        /* http://www.flickr.com/services/api/flickr.people.getPublicGroups.html */
798        $this->request("flickr.people.getPublicGroups", array("user_id"=>$user_id));
799        return $this->parsed_response ? $this->parsed_response['groups']['group'] : false;
800    }
801
802    function people_getPublicPhotos($user_id, $extras = NULL, $per_page = NULL, $page = NULL) {
803        /* http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html */
804        if (is_array($extras)) {
805            $extras = implode(",", $extras);
806        }
807
808        $this->request("flickr.people.getPublicPhotos", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
809        return $this->parsed_response ? $this->parsed_response['photos'] : false;
810    }
811
812    function people_getUploadStatus()
813    {
814        /* http://www.flickr.com/services/api/flickr.people.getUploadStatus.html */
815        /* Requires Authentication */
816        $this->request("flickr.people.getUploadStatus");
817        return $this->parsed_response ? $this->parsed_response['user'] : false;
818    }
819
820
821    /* Photos Methods */
822    function photos_addTags ($photo_id, $tags)
823    {
824        /* http://www.flickr.com/services/api/flickr.photos.addTags.html */
825        $this->request("flickr.photos.addTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE);
826        return $this->parsed_response ? true : false;
827    }
828
829    function photos_delete($photo_id)
830    {
831        /* http://www.flickr.com/services/api/flickr.photos.delete.html */
832        $this->request("flickr.photos.delete", array("photo_id"=>$photo_id), TRUE);
833        return $this->parsed_response ? true : false;
834    }
835
836    function photos_getAllContexts ($photo_id)
837    {
838        /* http://www.flickr.com/services/api/flickr.photos.getAllContexts.html */
839        $this->request("flickr.photos.getAllContexts", array("photo_id"=>$photo_id));
840        return $this->parsed_response ? $this->parsed_response : false;
841    }
842
843    function photos_getContactsPhotos ($count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL)
844    {
845        /* http://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html */
846        $this->request("flickr.photos.getContactsPhotos", array("count"=>$count, "just_friends"=>$just_friends, "single_photo"=>$single_photo, "include_self"=>$include_self, "extras"=>$extras));
847        return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
848    }
849
850    function photos_getContactsPublicPhotos ($user_id, $count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL)
851    {
852        /* http://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html */
853        $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));
854        return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
855    }
856
857    function photos_getContext ($photo_id)
858    {
859        /* http://www.flickr.com/services/api/flickr.photos.getContext.html */
860        $this->request("flickr.photos.getContext", array("photo_id"=>$photo_id));
861        return $this->parsed_response ? $this->parsed_response : false;
862    }
863
864    function photos_getCounts ($dates = NULL, $taken_dates = NULL)
865    {
866        /* http://www.flickr.com/services/api/flickr.photos.getCounts.html */
867        $this->request("flickr.photos.getCounts", array("dates"=>$dates, "taken_dates"=>$taken_dates));
868        return $this->parsed_response ? $this->parsed_response['photocounts']['photocount'] : false;
869    }
870
871    function photos_getExif ($photo_id, $secret = NULL)
872    {
873        /* http://www.flickr.com/services/api/flickr.photos.getExif.html */
874        $this->request("flickr.photos.getExif", array("photo_id"=>$photo_id, "secret"=>$secret));
875        return $this->parsed_response ? $this->parsed_response['photo'] : false;
876    }
877   
878    function photos_getFavorites($photo_id, $page = NULL, $per_page = NULL)
879    {
880        /* http://www.flickr.com/services/api/flickr.photos.getFavorites.html */
881        $this->request("flickr.photos.getFavorites", array("photo_id"=>$photo_id, "page"=>$page, "per_page"=>$per_page));
882        return $this->parsed_response ? $this->parsed_response['photo'] : false;
883    }
884
885    function photos_getInfo($photo_id, $secret = NULL)
886    {
887        /* http://www.flickr.com/services/api/flickr.photos.getInfo.html */
888        $this->request("flickr.photos.getInfo", array("photo_id"=>$photo_id, "secret"=>$secret));
889        return $this->parsed_response ? $this->parsed_response['photo'] : false;
890    }
891
892    function photos_getNotInSet($min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
893    {
894        /* http://www.flickr.com/services/api/flickr.photos.getNotInSet.html */
895        if (is_array($extras)) {
896            $extras = implode(",", $extras);
897        }
898        $this->request("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, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
899        return $this->parsed_response ? $this->parsed_response['photos'] : false;
900    }
901
902    function photos_getPerms($photo_id)
903    {
904        /* http://www.flickr.com/services/api/flickr.photos.getPerms.html */
905        $this->request("flickr.photos.getPerms", array("photo_id"=>$photo_id));
906        return $this->parsed_response ? $this->parsed_response['perms'] : false;
907    }
908
909    function photos_getRecent($extras = NULL, $per_page = NULL, $page = NULL)
910    {
911        /* http://www.flickr.com/services/api/flickr.photos.getRecent.html */
912
913        if (is_array($extras)) {
914            $extras = implode(",", $extras);
915        }
916        $this->request("flickr.photos.getRecent", array("extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
917        return $this->parsed_response ? $this->parsed_response['photos'] : false;
918    }
919
920    function photos_getSizes($photo_id)
921    {
922        /* http://www.flickr.com/services/api/flickr.photos.getSizes.html */
923        $this->request("flickr.photos.getSizes", array("photo_id"=>$photo_id));
924        return $this->parsed_response ? $this->parsed_response['sizes']['size'] : false;
925    }
926
927    function photos_getUntagged($min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
928    {
929        /* http://www.flickr.com/services/api/flickr.photos.getUntagged.html */
930        if (is_array($extras)) {
931            $extras = implode(",", $extras);
932        }
933        $this->request("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, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
934        return $this->parsed_response ? $this->parsed_response['photos'] : false;
935    }
936
937    function photos_getWithGeoData($args = NULL) {
938        /* See the documentation included with the photos_search() function.
939         * I'm using the same style of arguments for this function. The only
940         * difference here is that this doesn't require any arguments. The
941         * flickr.photos.search method requires at least one search parameter.
942         */
943        /* http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html */
944        if (is_null($args)) {
945            $args = array();
946        }
947        $this->request("flickr.photos.getWithGeoData", $args);
948        return $this->parsed_response ? $this->parsed_response['photos'] : false;
949    }
950
951    function photos_getWithoutGeoData($args = NULL) {
952        /* See the documentation included with the photos_search() function.
953         * I'm using the same style of arguments for this function. The only
954         * difference here is that this doesn't require any arguments. The
955         * flickr.photos.search method requires at least one search parameter.
956         */
957        /* http://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html */
958        if (is_null($args)) {
959            $args = array();
960        }
961        $this->request("flickr.photos.getWithoutGeoData", $args);
962        return $this->parsed_response ? $this->parsed_response['photos'] : false;
963    }
964
965    function photos_recentlyUpdated($min_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
966    {
967        /* http://www.flickr.com/services/api/flickr.photos.getUntagged.html */
968        if (is_array($extras)) {
969            $extras = implode(",", $extras);
970        }
971        $this->request("flickr.photos.recentlyUpdated", array("min_date"=>$min_date, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
972        return $this->parsed_response ? $this->parsed_response['photos'] : false;
973    }
974
975    function photos_removeTag($tag_id)
976    {
977        /* http://www.flickr.com/services/api/flickr.photos.removeTag.html */
978        $this->request("flickr.photos.removeTag", array("tag_id"=>$tag_id), TRUE);
979        return $this->parsed_response ? true : false;
980    }
981
982    function photos_search($args)
983    {
984        /* This function strays from the method of arguments that I've
985         * used in the other functions for the fact that there are just
986         * so many arguments to this API method. What you'll need to do
987         * is pass an associative array to the function containing the
988         * arguments you want to pass to the API.  For example:
989         *   $photos = $f->photos_search(array("tags"=>"brown,cow", "tag_mode"=>"any"));
990         * This will return photos tagged with either "brown" or "cow"
991         * or both. See the API documentation (link below) for a full
992         * list of arguments.
993         */
994
995        /* http://www.flickr.com/services/api/flickr.photos.search.html */
996        $this->request("flickr.photos.search", $args);
997        return $this->parsed_response ? $this->parsed_response['photos'] : false;
998    }
999
1000    function photos_setDates($photo_id, $date_posted = NULL, $date_taken = NULL, $date_taken_granularity = NULL)
1001    {
1002        /* http://www.flickr.com/services/api/flickr.photos.setDates.html */
1003        $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);
1004        return $this->parsed_response ? true : false;
1005    }
1006
1007    function photos_setMeta($photo_id, $title, $description)
1008    {
1009        /* http://www.flickr.com/services/api/flickr.photos.setMeta.html */
1010        $this->request("flickr.photos.setMeta", array("photo_id"=>$photo_id, "title"=>$title, "description"=>$description), TRUE);
1011        return $this->parsed_response ? true : false;
1012    }
1013
1014    function photos_setPerms($photo_id, $is_public, $is_friend, $is_family, $perm_comment, $perm_addmeta)
1015    {
1016        /* http://www.flickr.com/services/api/flickr.photos.setPerms.html */
1017        $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);
1018        return $this->parsed_response ? true : false;
1019    }
1020
1021    function photos_setTags($photo_id, $tags)
1022    {
1023        /* http://www.flickr.com/services/api/flickr.photos.setTags.html */
1024        $this->request("flickr.photos.setTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE);
1025        return $this->parsed_response ? true : false;
1026    }
1027
1028    /* Photos - Comments Methods */
1029    function photos_comments_addComment($photo_id, $comment_text) {
1030        /* http://www.flickr.com/services/api/flickr.photos.comments.addComment.html */
1031        $this->request("flickr.photos.comments.addComment", array("photo_id" => $photo_id, "comment_text"=>$comment_text), TRUE);
1032        return $this->parsed_response ? $this->parsed_response['comment'] : false;
1033    }
1034
1035    function photos_comments_deleteComment($comment_id) {
1036        /* http://www.flickr.com/services/api/flickr.photos.comments.deleteComment.html */
1037        $this->request("flickr.photos.comments.deleteComment", array("comment_id" => $comment_id), TRUE);
1038        return $this->parsed_response ? true : false;
1039    }
1040
1041    function photos_comments_editComment($comment_id, $comment_text) {
1042        /* http://www.flickr.com/services/api/flickr.photos.comments.editComment.html */
1043        $this->request("flickr.photos.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE);
1044        return $this->parsed_response ? true : false;
1045    }
1046
1047    function photos_comments_getList($photo_id)
1048    {
1049        /* http://www.flickr.com/services/api/flickr.photos.comments.getList.html */
1050        $this->request("flickr.photos.comments.getList", array("photo_id"=>$photo_id));
1051        return $this->parsed_response ? $this->parsed_response['comments'] : false;
1052    }
1053
1054    /* Photos - Geo Methods */
1055    function photos_geo_getLocation($photo_id)
1056    {
1057        /* http://www.flickr.com/services/api/flickr.photos.geo.getLocation.html */
1058        $this->request("flickr.photos.geo.getLocation", array("photo_id"=>$photo_id));
1059        return $this->parsed_response ? $this->parsed_response['photo'] : false;
1060    }
1061
1062    function photos_geo_getPerms($photo_id)
1063    {
1064        /* http://www.flickr.com/services/api/flickr.photos.geo.getPerms.html */
1065        $this->request("flickr.photos.geo.getPerms", array("photo_id"=>$photo_id));
1066        return $this->parsed_response ? $this->parsed_response['perms'] : false;
1067    }
1068
1069    function photos_geo_removeLocation($photo_id)
1070    {
1071        /* http://www.flickr.com/services/api/flickr.photos.geo.removeLocation.html */
1072        $this->request("flickr.photos.geo.removeLocation", array("photo_id"=>$photo_id), TRUE);
1073        return $this->parsed_response ? true : false;
1074    }
1075
1076    function photos_geo_setLocation($photo_id, $lat, $lon, $accuracy = NULL)
1077    {
1078        /* http://www.flickr.com/services/api/flickr.photos.geo.setLocation.html */
1079        $this->request("flickr.photos.geo.setLocation", array("photo_id"=>$photo_id, "lat"=>$lat, "lon"=>$lon, "accuracy"=>$accuracy), TRUE);
1080        return $this->parsed_response ? true : false;
1081    }
1082
1083    function photos_geo_setPerms($photo_id, $is_public, $is_contact, $is_friend, $is_family)
1084    {
1085        /* http://www.flickr.com/services/api/flickr.photos.geo.setPerms.html */
1086        $this->request("flickr.photos.geo.setPerms", array("photo_id"=>$photo_id, "is_public"=>$is_public, "is_contact"=>$is_contact, "is_friend"=>$is_friend, "is_family"=>$is_family), TRUE);
1087        return $this->parsed_response ? true : false;
1088    }
1089
1090    /* Photos - Licenses Methods */
1091    function photos_licenses_getInfo()
1092    {
1093        /* http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html */
1094        $this->request("flickr.photos.licenses.getInfo");
1095        return $this->parsed_response ? $this->parsed_response['licenses']['license'] : false;
1096    }
1097
1098    function photos_licenses_setLicense($photo_id, $license_id)
1099    {
1100        /* http://www.flickr.com/services/api/flickr.photos.licenses.setLicense.html */
1101        /* Requires Authentication */
1102        $this->request("flickr.photos.licenses.setLicense", array("photo_id"=>$photo_id, "license_id"=>$license_id), TRUE);
1103        return $this->parsed_response ? true : false;
1104    }
1105
1106    /* Photos - Notes Methods */
1107    function photos_notes_add($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text)
1108    {
1109        /* http://www.flickr.com/services/api/flickr.photos.notes.add.html */
1110        $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);
1111        return $this->parsed_response ? $this->parsed_response['note'] : false;
1112    }
1113
1114    function photos_notes_delete($note_id)
1115    {
1116        /* http://www.flickr.com/services/api/flickr.photos.notes.delete.html */
1117        $this->request("flickr.photos.notes.delete", array("note_id" => $note_id), TRUE);
1118        return $this->parsed_response ? true : false;
1119    }
1120
1121    function photos_notes_edit($note_id, $note_x, $note_y, $note_w, $note_h, $note_text)
1122    {
1123        /* http://www.flickr.com/services/api/flickr.photos.notes.edit.html */
1124        $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);
1125        return $this->parsed_response ? true : false;
1126    }
1127
1128    /* Photos - Transform Methods */
1129    function photos_transform_rotate($photo_id, $degrees)
1130    {
1131        /* http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */
1132        $this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE);
1133        return $this->parsed_response ? true : false;
1134    }
1135
1136    /* Photos - Upload Methods */
1137    function photos_upload_checkTickets($tickets)
1138    {
1139        /* http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html */
1140        if (is_array($tickets)) {
1141            $tickets = implode(",", $tickets);
1142        }
1143        $this->request("flickr.photos.upload.checkTickets", array("tickets" => $tickets), TRUE);
1144        return $this->parsed_response ? $this->parsed_response['uploader']['ticket'] : false;
1145    }
1146
1147    /* Photosets Methods */
1148    function photosets_addPhoto($photoset_id, $photo_id)
1149    {
1150        /* http://www.flickr.com/services/api/flickr.photosets.addPhoto.html */
1151        $this->request("flickr.photosets.addPhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE);
1152        return $this->parsed_response ? true : false;
1153    }
1154
1155    function photosets_create($title, $description, $primary_photo_id)
1156    {
1157        /* http://www.flickr.com/services/api/flickr.photosets.create.html */
1158        $this->request("flickr.photosets.create", array("title" => $title, "primary_photo_id" => $primary_photo_id, "description" => $description), TRUE);
1159        return $this->parsed_response ? $this->parsed_response['photoset'] : false;
1160    }
1161
1162    function photosets_delete($photoset_id)
1163    {
1164        /* http://www.flickr.com/services/api/flickr.photosets.delete.html */
1165        $this->request("flickr.photosets.delete", array("photoset_id" => $photoset_id), TRUE);
1166        return $this->parsed_response ? true : false;
1167    }
1168
1169    function photosets_editMeta($photoset_id, $title, $description = NULL)
1170    {
1171        /* http://www.flickr.com/services/api/flickr.photosets.editMeta.html */
1172        $this->request("flickr.photosets.editMeta", array("photoset_id" => $photoset_id, "title" => $title, "description" => $description), TRUE);
1173        return $this->parsed_response ? true : false;
1174    }
1175
1176    function photosets_editPhotos($photoset_id, $primary_photo_id, $photo_ids)
1177    {
1178        /* http://www.flickr.com/services/api/flickr.photosets.editPhotos.html */
1179        $this->request("flickr.photosets.editPhotos", array("photoset_id" => $photoset_id, "primary_photo_id" => $primary_photo_id, "photo_ids" => $photo_ids), TRUE);
1180        return $this->parsed_response ? true : false;
1181    }
1182
1183    function photosets_getContext($photo_id, $photoset_id)
1184    {
1185        /* http://www.flickr.com/services/api/flickr.photosets.getContext.html */
1186        $this->request("flickr.photosets.getContext", array("photo_id" => $photo_id, "photoset_id" => $photoset_id));
1187        return $this->parsed_response ? $this->parsed_response : false;
1188    }
1189
1190    function photosets_getInfo($photoset_id)
1191    {
1192        /* http://www.flickr.com/services/api/flickr.photosets.getInfo.html */
1193        $this->request("flickr.photosets.getInfo", array("photoset_id" => $photoset_id));
1194        return $this->parsed_response ? $this->parsed_response['photoset'] : false;
1195    }
1196
1197    function photosets_getList($user_id = NULL)
1198    {
1199        /* http://www.flickr.com/services/api/flickr.photosets.getList.html */
1200        $this->request("flickr.photosets.getList", array("user_id" => $user_id));
1201        return $this->parsed_response ? $this->parsed_response['photosets'] : false;
1202    }
1203
1204    function photosets_getPhotos($photoset_id, $extras = NULL, $privacy_filter = NULL, $per_page = NULL, $page = NULL)
1205    {
1206        /* http://www.flickr.com/services/api/flickr.photosets.getPhotos.html */
1207        $this->request("flickr.photosets.getPhotos", array("photoset_id" => $photoset_id, "extras" => $extras, "privacy_filter" => $privacy_filter, "per_page" => $per_page, "page" => $page));
1208        return $this->parsed_response ? $this->parsed_response['photoset'] : false;
1209    }
1210
1211    function photosets_orderSets($photoset_ids)
1212    {
1213        /* http://www.flickr.com/services/api/flickr.photosets.orderSets.html */
1214        if (is_array($photoset_ids)) {
1215            $photoset_ids = implode(",", $photoset_ids);
1216        }
1217        $this->request("flickr.photosets.orderSets", array("photoset_ids" => $photoset_ids), TRUE);
1218        return $this->parsed_response ? true : false;
1219    }
1220
1221    function photosets_removePhoto($photoset_id, $photo_id)
1222    {
1223        /* http://www.flickr.com/services/api/flickr.photosets.removePhoto.html */
1224        $this->request("flickr.photosets.removePhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE);
1225        return $this->parsed_response ? true : false;
1226    }
1227
1228    /* Photosets Comments Methods */
1229    function photosets_comments_addComment($photoset_id, $comment_text) {
1230        /* http://www.flickr.com/services/api/flickr.photosets.comments.addComment.html */
1231        $this->request("flickr.photosets.comments.addComment", array("photoset_id" => $photoset_id, "comment_text"=>$comment_text), TRUE);
1232        return $this->parsed_response ? $this->parsed_response['comment'] : false;
1233    }
1234
1235    function photosets_comments_deleteComment($comment_id) {
1236        /* http://www.flickr.com/services/api/flickr.photosets.comments.deleteComment.html */
1237        $this->request("flickr.photosets.comments.deleteComment", array("comment_id" => $comment_id), TRUE);
1238        return $this->parsed_response ? true : false;
1239    }
1240
1241    function photosets_comments_editComment($comment_id, $comment_text) {
1242        /* http://www.flickr.com/services/api/flickr.photosets.comments.editComment.html */
1243        $this->request("flickr.photosets.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE);
1244        return $this->parsed_response ? true : false;
1245    }
1246
1247    function photosets_comments_getList($photoset_id)
1248    {
1249        /* http://www.flickr.com/services/api/flickr.photosets.comments.getList.html */
1250        $this->request("flickr.photosets.comments.getList", array("photoset_id"=>$photoset_id));
1251        return $this->parsed_response ? $this->parsed_response['comments'] : false;
1252    }
1253
1254    /* Reflection Methods */
1255    function reflection_getMethodInfo($method_name)
1256    {
1257        /* http://www.flickr.com/services/api/flickr.reflection.getMethodInfo.html */
1258        $this->request("flickr.reflection.getMethodInfo", array("method_name" => $method_name));
1259        return $this->parsed_response ? $this->parsed_response : false;
1260    }
1261
1262    function reflection_getMethods()
1263    {
1264        /* http://www.flickr.com/services/api/flickr.reflection.getMethods.html */
1265        $this->request("flickr.reflection.getMethods");
1266        return $this->parsed_response ? $this->parsed_response['methods']['method'] : false;
1267    }
1268
1269    /* Tags Methods */
1270    function tags_getHotList($period = NULL, $count = NULL)
1271    {
1272        /* http://www.flickr.com/services/api/flickr.tags.getHotList.html */
1273        $this->request("flickr.tags.getHotList", array("period" => $period, "count" => $count));
1274        return $this->parsed_response ? $this->parsed_response['hottags'] : false;
1275    }
1276
1277    function tags_getListPhoto($photo_id)
1278    {
1279        /* http://www.flickr.com/services/api/flickr.tags.getListPhoto.html */
1280        $this->request("flickr.tags.getListPhoto", array("photo_id" => $photo_id));
1281        return $this->parsed_response ? $this->parsed_response['photo']['tags']['tag'] : false;
1282    }
1283
1284    function tags_getListUser($user_id = NULL)
1285    {
1286        /* http://www.flickr.com/services/api/flickr.tags.getListUser.html */
1287        $this->request("flickr.tags.getListUser", array("user_id" => $user_id));
1288        return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false;
1289    }
1290
1291    function tags_getListUserPopular($user_id = NULL, $count = NULL)
1292    {
1293        /* http://www.flickr.com/services/api/flickr.tags.getListUserPopular.html */
1294        $this->request("flickr.tags.getListUserPopular", array("user_id" => $user_id, "count" => $count));
1295        return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false;
1296    }
1297
1298    function tags_getListUserRaw($tag)
1299    {
1300        /* http://www.flickr.com/services/api/flickr.tags.getListUserRaw.html */
1301        $this->request("flickr.tags.getListUserRaw", array("tag" => $tag));
1302        return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'][0]['raw'] : false;
1303    }
1304
1305    function tags_getRelated($tag)
1306    {
1307        /* http://www.flickr.com/services/api/flickr.tags.getRelated.html */
1308        $this->request("flickr.tags.getRelated", array("tag" => $tag));
1309        return $this->parsed_response ? $this->parsed_response['tags'] : false;
1310    }
1311
1312    function test_echo($args = array())
1313    {
1314        /* http://www.flickr.com/services/api/flickr.test.echo.html */
1315        $this->request("flickr.test.echo", $args);
1316        return $this->parsed_response ? $this->parsed_response : false;
1317    }
1318
1319    function test_login()
1320    {
1321        /* http://www.flickr.com/services/api/flickr.test.login.html */
1322        $this->request("flickr.test.login");
1323        return $this->parsed_response ? $this->parsed_response['user'] : false;
1324    }
1325
1326    function urls_getGroup($group_id)
1327    {
1328        /* http://www.flickr.com/services/api/flickr.urls.getGroup.html */
1329        $this->request("flickr.urls.getGroup", array("group_id"=>$group_id));
1330        return $this->parsed_response ? $this->parsed_response['group']['url'] : false;
1331    }
1332
1333    function urls_getUserPhotos($user_id = NULL)
1334    {
1335        /* http://www.flickr.com/services/api/flickr.urls.getUserPhotos.html */
1336        $this->request("flickr.urls.getUserPhotos", array("user_id"=>$user_id));
1337        return $this->parsed_response ? $this->parsed_response['user']['url'] : false;
1338    }
1339
1340    function urls_getUserProfile($user_id = NULL)
1341    {
1342        /* http://www.flickr.com/services/api/flickr.urls.getUserProfile.html */
1343        $this->request("flickr.urls.getUserProfile", array("user_id"=>$user_id));
1344        return $this->parsed_response ? $this->parsed_response['user']['url'] : false;
1345    }
1346
1347    function urls_lookupGroup($url)
1348    {
1349        /* http://www.flickr.com/services/api/flickr.urls.lookupGroup.html */
1350        $this->request("flickr.urls.lookupGroup", array("url"=>$url));
1351        return $this->parsed_response ? $this->parsed_response['group'] : false;
1352    }
1353
1354    function urls_lookupUser($url)
1355    {
1356        /* http://www.flickr.com/services/api/flickr.photos.notes.edit.html */
1357        $this->request("flickr.urls.lookupUser", array("url"=>$url));
1358        return $this->parsed_response ? $this->parsed_response['user'] : false;
1359    }
1360}
1361
1362
1363?>
Note: See TracBrowser for help on using the repository browser.

Sites map