PageRenderTime 75ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/flickrlib.php

https://bitbucket.org/ngmares/moodle
PHP | 1152 lines | 761 code | 146 blank | 245 comment | 53 complexity | 5f6a03a5a9277b6679d46c33249e2b1d MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0, MPL-2.0-no-copyleft-exception, GPL-3.0, Apache-2.0, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * phpFlickr Class 2.2.0
  4. * Written by Dan Coulter (dan@dancoulter.com)
  5. * Sourceforge Project Page: {@link http://www.sourceforge.net/projects/phpflickr/}
  6. * Released under GNU Lesser General Public License ({@link http://www.gnu.org/copyleft/lgpl.html})
  7. * For more information about the class and upcoming tools and toys using it,
  8. * visit {@link http://www.phpflickr.com/} or {@link http://phpflickr.sourceforge.net}
  9. *
  10. * For installation instructions, open the README.txt file packaged with this
  11. * class. If you don't have a copy, you can see it at:
  12. * {@link http://www.phpflickr.com/README.txt}
  13. *
  14. * Please submit all problems or questions to the Help Forum on my project page:
  15. * {@link http://sourceforge.net/forum/forum.php?forum_id=469652}
  16. *
  17. * Modified by Dongsheng Cai <dongsheng@moodle.com>
  18. * ChangeLog:
  19. * 1. Remove PEAR HTTP LIB, use curl.class.php (created by myself)
  20. * 2. Remove PEAR DB LIB
  21. * 3. Remove all cache code, it will implement in curl class.
  22. * 4. Clean up session code
  23. *
  24. * Modified by David Mudrak <david@moodle.com>
  25. * ChangeLog:
  26. * 1. upload() method uses Moodle stored_file
  27. * 2. upload() method supports all params provided by http://www.flickr.com/services/api/upload.api.html
  28. *
  29. * @package moodlecore
  30. * @subpackage 3rd-party
  31. */
  32. /**
  33. * Flickr Class
  34. * @package moodlecore
  35. * @subpackage 3rd-party
  36. */
  37. class phpFlickr {
  38. var $api_key;
  39. var $secret;
  40. var $REST = 'http://api.flickr.com/services/rest/';
  41. var $Upload = 'http://api.flickr.com/services/upload/';
  42. var $Replace = 'http://api.flickr.com/services/replace/';
  43. var $req;
  44. var $response;
  45. var $parsed_response;
  46. var $die_on_error;
  47. var $error_code;
  48. var $error_msg;
  49. var $token;
  50. var $php_version;
  51. /**
  52. * When your database cache table hits this many rows, a cleanup
  53. * will occur to get rid of all of the old rows and cleanup the
  54. * garbage in the table. For most personal apps, 1000 rows should
  55. * be more than enough. If your site gets hit by a lot of traffic
  56. * or you have a lot of disk space to spare, bump this number up.
  57. * You should try to set it high enough that the cleanup only
  58. * happens every once in a while, so this will depend on the growth
  59. * of your table.
  60. *
  61. * @global object
  62. */
  63. function __construct ($api_key, $secret = NULL, $token = '')
  64. {
  65. global $CFG;
  66. //The API Key must be set before any calls can be made. You can
  67. //get your own at http://www.flickr.com/services/api/misc.api_keys.html
  68. $this->api_key = $api_key;
  69. $this->secret = $secret;
  70. $this->die_on_error = false;
  71. $this->service = "flickr";
  72. $this->token = $token;
  73. //Find the PHP version and store it for future reference
  74. $this->php_version = explode("-", phpversion());
  75. $this->php_version = explode(".", $this->php_version[0]);
  76. $this->curl = new curl(array('cache'=>true, 'module_cache'=>'repository'));
  77. }
  78. function request ($command, $args = array())
  79. {
  80. //Sends a request to Flickr's REST endpoint via POST.
  81. if (substr($command,0,7) != "flickr.") {
  82. $command = "flickr." . $command;
  83. }
  84. //Process arguments, including method and login data.
  85. if ($command == 'flickr.upload') {
  86. $photo = $args['photo'];
  87. if (empty($args['is_public'])) {
  88. $args['is_public'] = 0;
  89. }
  90. if (empty($args['is_friend'])) {
  91. $args['is_friend'] = 0;
  92. }
  93. if (empty($args['is_family'])) {
  94. $args['is_family'] = 0;
  95. }
  96. if (empty($args['hidden'])) {
  97. $args['hidden'] = 1;
  98. }
  99. $args = array("api_key" => $this->api_key,
  100. "title" => $args['title'],
  101. "description" => $args['description'],
  102. "tags" => $args['tags'],
  103. "is_public" => $args['is_public'],
  104. "is_friend" => $args['is_friend'],
  105. "is_family" => $args['is_family'],
  106. "safety_level" => $args['safety_level'],
  107. "content_type" => $args['content_type'],
  108. "hidden" => $args['hidden']);
  109. } else {
  110. $args = array_merge(array("method" => $command, "format" => "php_serial", "api_key" => $this->api_key), $args);
  111. }
  112. if (!empty($this->token)) {
  113. $args = array_merge($args, array("auth_token" => $this->token));
  114. }
  115. ksort($args);
  116. $auth_sig = "";
  117. foreach ($args as $key => $data) {
  118. $auth_sig .= $key . $data;
  119. }
  120. if (!empty($this->secret)) {
  121. $api_sig = md5($this->secret . $auth_sig);
  122. $args['api_sig'] = $api_sig;
  123. }
  124. //$this->req->addHeader("Connection", "Keep-Alive");
  125. if ($command != 'flickr.upload') {
  126. $ret = $this->curl->post($this->REST, $args);
  127. $this->parsed_response = $this->clean_text_nodes(unserialize($ret));
  128. } else {
  129. $args['photo'] = $photo;
  130. $xml = simplexml_load_string($this->curl->post($this->Upload, $args));
  131. if ($xml['stat'] == 'fail') {
  132. $this->parsed_response = array('stat' => (string) $xml['stat'], 'code' => (int) $xml->err['code'], 'message' => (string) $xml->err['msg']);
  133. } elseif ($xml['stat'] == 'ok') {
  134. $this->parsed_response = array('stat' => (string) $xml['stat'], 'photoid' => (int) $xml->photoid);
  135. $this->response = true;
  136. }
  137. }
  138. if ($this->parsed_response['stat'] == 'fail') {
  139. if ($this->die_on_error) die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
  140. else {
  141. $this->error_code = $this->parsed_response['code'];
  142. $this->error_msg = $this->parsed_response['message'];
  143. $this->parsed_response = false;
  144. }
  145. } else {
  146. $this->error_code = false;
  147. $this->error_msg = false;
  148. }
  149. return $this->response;
  150. }
  151. function clean_text_nodes($arr) {
  152. if (!is_array($arr)) {
  153. return $arr;
  154. } elseif (count($arr) == 0) {
  155. return $arr;
  156. } elseif (count($arr) == 1 && array_key_exists('_content', $arr)) {
  157. return $arr['_content'];
  158. } else {
  159. foreach ($arr as $key => $element) {
  160. $arr[$key] = $this->clean_text_nodes($element);
  161. }
  162. return($arr);
  163. }
  164. }
  165. function setToken($token)
  166. {
  167. // Sets an authentication token to use instead of the session variable
  168. $this->token = $token;
  169. }
  170. function setProxy($server, $port)
  171. {
  172. // Sets the proxy for all phpFlickr calls.
  173. //$this->req->setProxy($server, $port);
  174. }
  175. function getErrorCode()
  176. {
  177. // Returns the error code of the last call. If the last call did not
  178. // return an error. This will return a false boolean.
  179. return $this->error_code;
  180. }
  181. function getErrorMsg()
  182. {
  183. // Returns the error message of the last call. If the last call did not
  184. // return an error. This will return a false boolean.
  185. return $this->error_msg;
  186. }
  187. /** These functions are front ends for the flickr calls */
  188. function buildPhotoURL ($photo, $size = "Medium")
  189. {
  190. //receives an array (can use the individual photo data returned
  191. //from an API call) and returns a URL (doesn't mean that the
  192. //file size exists)
  193. $sizes = array(
  194. "square" => "_s",
  195. "thumbnail" => "_t",
  196. "small" => "_m",
  197. "medium" => "",
  198. "large" => "_b",
  199. "original" => "_o"
  200. );
  201. $size = strtolower($size);
  202. if (!array_key_exists($size, $sizes)) {
  203. $size = "medium";
  204. }
  205. if ($size == "original") {
  206. $url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['originalsecret'] . "_o" . "." . $photo['originalformat'];
  207. } else {
  208. $url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes[$size] . ".jpg";
  209. }
  210. return $url;
  211. }
  212. function getFriendlyGeodata($lat, $lon) {
  213. /** I've added this method to get the friendly geodata (i.e. 'in New York, NY') that the
  214. * website provides, but isn't available in the API. I'm providing this service as long
  215. * as it doesn't flood my server with requests and crash it all the time.
  216. */
  217. return unserialize(file_get_contents('http://phpflickr.com/geodata/?format=php&lat=' . $lat . '&lon=' . $lon));
  218. }
  219. function auth ($perms = "write", $remember_uri = true)
  220. {
  221. // Redirects to Flickr's authentication piece if there is no valid token.
  222. // If remember_uri is set to false, the callback script (included) will
  223. // redirect to its default page.
  224. if ($remember_uri) {
  225. $redirect = qualified_me(); // TODO: this is not used, why?
  226. }
  227. $api_sig = md5($this->secret . "api_key" . $this->api_key . "perms" . $perms);
  228. $url = 'http://www.flickr.com/services/auth/?api_key=' . $this->api_key . "&perms=" . $perms . '&api_sig='. $api_sig;
  229. return $url;
  230. }
  231. /**
  232. * To use the phpFlickr::call method, pass a string containing the API method you want
  233. * to use and an associative array of arguments. For example:
  234. * $result = $f->call("flickr.photos.comments.getList", array("photo_id"=>'34952612'));
  235. * This method will allow you to make calls to arbitrary methods that haven't been
  236. * implemented in phpFlickr yet.
  237. */
  238. function call($method, $arguments)
  239. {
  240. $this->request($method, $arguments);
  241. return $this->parsed_response ? $this->parsed_response : false;
  242. }
  243. /**
  244. * These functions are the direct implementations of flickr calls.
  245. * For method documentation, including arguments, visit the address
  246. * included in a comment in the function.
  247. */
  248. /** Activity methods */
  249. function activity_userComments ($per_page = NULL, $page = NULL)
  250. {
  251. /** http://www.flickr.com/services/api/flickr.activity.userComments.html */
  252. $this->request('flickr.activity.userComments', array("per_page" => $per_page, "page" => $page));
  253. return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
  254. }
  255. function activity_userPhotos ($timeframe = NULL, $per_page = NULL, $page = NULL)
  256. {
  257. /** http://www.flickr.com/services/api/flickr.activity.userPhotos.html */
  258. $this->request('flickr.activity.userPhotos', array("timeframe" => $timeframe, "per_page" => $per_page, "page" => $page));
  259. return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
  260. }
  261. /** Authentication methods */
  262. function auth_checkToken ()
  263. {
  264. /** http://www.flickr.com/services/api/flickr.auth.checkToken.html */
  265. $this->request('flickr.auth.checkToken');
  266. return $this->parsed_response ? $this->parsed_response['auth'] : false;
  267. }
  268. function auth_getFrob ()
  269. {
  270. /** http://www.flickr.com/services/api/flickr.auth.getFrob.html */
  271. $this->request('flickr.auth.getFrob');
  272. return $this->parsed_response ? $this->parsed_response['frob'] : false;
  273. }
  274. function auth_getFullToken ($mini_token)
  275. {
  276. /** http://www.flickr.com/services/api/flickr.auth.getFullToken.html */
  277. $this->request('flickr.auth.getFullToken', array('mini_token'=>$mini_token));
  278. return $this->parsed_response ? $this->parsed_response['auth'] : false;
  279. }
  280. function auth_getToken ($frob)
  281. {
  282. /** http://www.flickr.com/services/api/flickr.auth.getToken.html */
  283. $this->request('flickr.auth.getToken', array('frob'=>$frob));
  284. $this->token = $this->parsed_response['auth']['token'];
  285. return $this->parsed_response ? $this->parsed_response['auth'] : false;
  286. }
  287. /** Blogs methods */
  288. function blogs_getList ()
  289. {
  290. /** http://www.flickr.com/services/api/flickr.blogs.getList.html */
  291. $this->request('flickr.blogs.getList');
  292. return $this->parsed_response ? $this->parsed_response['blogs']['blog'] : false;
  293. }
  294. function blogs_postPhoto($blog_id, $photo_id, $title, $description, $blog_password = NULL)
  295. {
  296. /** http://www.flickr.com/services/api/flickr.blogs.postPhoto.html */
  297. $this->request('flickr.blogs.postPhoto', array('blog_id'=>$blog_id, 'photo_id'=>$photo_id, 'title'=>$title, 'description'=>$description, 'blog_password'=>$blog_password), TRUE);
  298. return $this->parsed_response ? true : false;
  299. }
  300. /** Contacts Methods */
  301. function contacts_getList ($filter = NULL, $page = NULL, $per_page = NULL)
  302. {
  303. /** http://www.flickr.com/services/api/flickr.contacts.getList.html */
  304. $this->request('flickr.contacts.getList', array('filter'=>$filter, 'page'=>$page, 'per_page'=>$per_page));
  305. return $this->parsed_response ? $this->parsed_response['contacts'] : false;
  306. }
  307. function contacts_getPublicList($user_id, $page = NULL, $per_page = NULL)
  308. {
  309. /** http://www.flickr.com/services/api/flickr.contacts.getPublicList.html */
  310. $this->request('flickr.contacts.getPublicList', array('user_id'=>$user_id, 'page'=>$page, 'per_page'=>$per_page));
  311. return $this->parsed_response ? $this->parsed_response['contacts'] : false;
  312. }
  313. /** Favorites Methods */
  314. function favorites_add ($photo_id)
  315. {
  316. /** http://www.flickr.com/services/api/flickr.favorites.add.html */
  317. $this->request('flickr.favorites.add', array('photo_id'=>$photo_id), TRUE);
  318. return $this->parsed_response ? true : false;
  319. }
  320. function favorites_getList($user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
  321. {
  322. /** http://www.flickr.com/services/api/flickr.favorites.getList.html */
  323. if (is_array($extras)) { $extras = implode(",", $extras); }
  324. $this->request("flickr.favorites.getList", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
  325. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  326. }
  327. function favorites_getPublicList($user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
  328. {
  329. /** http://www.flickr.com/services/api/flickr.favorites.getPublicList.html */
  330. if (is_array($extras)) {
  331. $extras = implode(",", $extras);
  332. }
  333. $this->request("flickr.favorites.getPublicList", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
  334. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  335. }
  336. function favorites_remove($photo_id)
  337. {
  338. /** http://www.flickr.com/services/api/flickr.favorites.remove.html */
  339. $this->request("flickr.favorites.remove", array("photo_id"=>$photo_id), TRUE);
  340. return $this->parsed_response ? true : false;
  341. }
  342. /** Groups Methods */
  343. function groups_browse ($cat_id = NULL)
  344. {
  345. /** http://www.flickr.com/services/api/flickr.groups.browse.html */
  346. $this->request("flickr.groups.browse", array("cat_id"=>$cat_id));
  347. return $this->parsed_response ? $this->parsed_response['category'] : false;
  348. }
  349. function groups_getInfo ($group_id)
  350. {
  351. /** http://www.flickr.com/services/api/flickr.groups.getInfo.html */
  352. $this->request("flickr.groups.getInfo", array("group_id"=>$group_id));
  353. return $this->parsed_response ? $this->parsed_response['group'] : false;
  354. }
  355. function groups_search ($text, $per_page=NULL, $page=NULL)
  356. {
  357. /** http://www.flickr.com/services/api/flickr.groups.search.html */
  358. $this->request("flickr.groups.search", array("text"=>$text,"per_page"=>$per_page,"page"=>$page));
  359. return $this->parsed_response ? $this->parsed_response['groups'] : false;
  360. }
  361. /** Groups Pools Methods */
  362. function groups_pools_add ($photo_id, $group_id)
  363. {
  364. /** http://www.flickr.com/services/api/flickr.groups.pools.add.html */
  365. $this->request("flickr.groups.pools.add", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
  366. return $this->parsed_response ? true : false;
  367. }
  368. function groups_pools_getContext ($photo_id, $group_id)
  369. {
  370. /** http://www.flickr.com/services/api/flickr.groups.pools.getContext.html */
  371. $this->request("flickr.groups.pools.getContext", array("photo_id"=>$photo_id, "group_id"=>$group_id));
  372. return $this->parsed_response ? $this->parsed_response : false;
  373. }
  374. function groups_pools_getGroups ($page = NULL, $per_page = NULL)
  375. {
  376. /** http://www.flickr.com/services/api/flickr.groups.pools.getGroups.html */
  377. $this->request("flickr.groups.pools.getGroups", array('page'=>$page, 'per_page'=>$per_page));
  378. return $this->parsed_response ? $this->parsed_response['groups'] : false;
  379. }
  380. function groups_pools_getPhotos ($group_id, $tags = NULL, $user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
  381. {
  382. /** http://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html */
  383. if (is_array($extras)) {
  384. $extras = implode(",", $extras);
  385. }
  386. $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));
  387. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  388. }
  389. function groups_pools_remove ($photo_id, $group_id)
  390. {
  391. /** http://www.flickr.com/services/api/flickr.groups.pools.remove.html */
  392. $this->request("flickr.groups.pools.remove", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
  393. return $this->parsed_response ? true : false;
  394. }
  395. /** Interestingness methods */
  396. function interestingness_getList($date = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
  397. {
  398. /** http://www.flickr.com/services/api/flickr.interestingness.getList.html */
  399. if (is_array($extras)) {
  400. $extras = implode(",", $extras);
  401. }
  402. $this->request("flickr.interestingness.getList", array("date"=>$date, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
  403. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  404. }
  405. /** People methods */
  406. function people_findByEmail ($find_email)
  407. {
  408. /** http://www.flickr.com/services/api/flickr.people.findByEmail.html */
  409. $this->request("flickr.people.findByEmail", array("find_email"=>$find_email));
  410. return $this->parsed_response ? $this->parsed_response['user'] : false;
  411. }
  412. function people_findByUsername ($username)
  413. {
  414. /** http://www.flickr.com/services/api/flickr.people.findByUsername.html */
  415. $this->request("flickr.people.findByUsername", array("username"=>$username));
  416. return $this->parsed_response ? $this->parsed_response['user'] : false;
  417. }
  418. function people_getInfo($user_id)
  419. {
  420. /** http://www.flickr.com/services/api/flickr.people.getInfo.html */
  421. $this->request("flickr.people.getInfo", array("user_id"=>$user_id));
  422. return $this->parsed_response ? $this->parsed_response['person'] : false;
  423. }
  424. function people_getPublicGroups($user_id)
  425. {
  426. /** http://www.flickr.com/services/api/flickr.people.getPublicGroups.html */
  427. $this->request("flickr.people.getPublicGroups", array("user_id"=>$user_id));
  428. return $this->parsed_response ? $this->parsed_response['groups']['group'] : false;
  429. }
  430. function people_getPublicPhotos($user_id, $extras = NULL, $per_page = NULL, $page = NULL) {
  431. /** http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html */
  432. if (is_array($extras)) {
  433. $extras = implode(",", $extras);
  434. }
  435. $this->request("flickr.people.getPublicPhotos", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
  436. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  437. }
  438. function people_getUploadStatus()
  439. {
  440. /** http://www.flickr.com/services/api/flickr.people.getUploadStatus.html */
  441. /** Requires Authentication */
  442. $this->request("flickr.people.getUploadStatus");
  443. return $this->parsed_response ? $this->parsed_response['user'] : false;
  444. }
  445. /** Photos Methods */
  446. function photos_addTags ($photo_id, $tags)
  447. {
  448. /** http://www.flickr.com/services/api/flickr.photos.addTags.html */
  449. $this->request("flickr.photos.addTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE);
  450. return $this->parsed_response ? true : false;
  451. }
  452. function photos_delete($photo_id)
  453. {
  454. /** http://www.flickr.com/services/api/flickr.photos.delete.html */
  455. $this->request("flickr.photos.delete", array("photo_id"=>$photo_id), TRUE);
  456. return $this->parsed_response ? true : false;
  457. }
  458. function photos_getAllContexts ($photo_id)
  459. {
  460. /** http://www.flickr.com/services/api/flickr.photos.getAllContexts.html */
  461. $this->request("flickr.photos.getAllContexts", array("photo_id"=>$photo_id));
  462. return $this->parsed_response ? $this->parsed_response : false;
  463. }
  464. function photos_getContactsPhotos ($count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL)
  465. {
  466. /** http://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html */
  467. $this->request("flickr.photos.getContactsPhotos", array("count"=>$count, "just_friends"=>$just_friends, "single_photo"=>$single_photo, "include_self"=>$include_self, "extras"=>$extras));
  468. return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
  469. }
  470. function photos_getContactsPublicPhotos ($user_id, $count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL)
  471. {
  472. /** http://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html */
  473. $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));
  474. return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
  475. }
  476. function photos_getContext ($photo_id)
  477. {
  478. /** http://www.flickr.com/services/api/flickr.photos.getContext.html */
  479. $this->request("flickr.photos.getContext", array("photo_id"=>$photo_id));
  480. return $this->parsed_response ? $this->parsed_response : false;
  481. }
  482. function photos_getCounts ($dates = NULL, $taken_dates = NULL)
  483. {
  484. /** http://www.flickr.com/services/api/flickr.photos.getCounts.html */
  485. $this->request("flickr.photos.getCounts", array("dates"=>$dates, "taken_dates"=>$taken_dates));
  486. return $this->parsed_response ? $this->parsed_response['photocounts']['photocount'] : false;
  487. }
  488. function photos_getExif ($photo_id, $secret = NULL)
  489. {
  490. /** http://www.flickr.com/services/api/flickr.photos.getExif.html */
  491. $this->request("flickr.photos.getExif", array("photo_id"=>$photo_id, "secret"=>$secret));
  492. return $this->parsed_response ? $this->parsed_response['photo'] : false;
  493. }
  494. function photos_getFavorites($photo_id, $page = NULL, $per_page = NULL)
  495. {
  496. /** http://www.flickr.com/services/api/flickr.photos.getFavorites.html */
  497. $this->request("flickr.photos.getFavorites", array("photo_id"=>$photo_id, "page"=>$page, "per_page"=>$per_page));
  498. return $this->parsed_response ? $this->parsed_response['photo'] : false;
  499. }
  500. function photos_getInfo($photo_id, $secret = NULL)
  501. {
  502. /** http://www.flickr.com/services/api/flickr.photos.getInfo.html */
  503. $this->request("flickr.photos.getInfo", array("photo_id"=>$photo_id, "secret"=>$secret));
  504. return $this->parsed_response ? $this->parsed_response['photo'] : false;
  505. }
  506. 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)
  507. {
  508. /** http://www.flickr.com/services/api/flickr.photos.getNotInSet.html */
  509. if (is_array($extras)) {
  510. $extras = implode(",", $extras);
  511. }
  512. $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));
  513. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  514. }
  515. function photos_getPerms($photo_id)
  516. {
  517. /** http://www.flickr.com/services/api/flickr.photos.getPerms.html */
  518. $this->request("flickr.photos.getPerms", array("photo_id"=>$photo_id));
  519. return $this->parsed_response ? $this->parsed_response['perms'] : false;
  520. }
  521. function photos_getRecent($extras = NULL, $per_page = NULL, $page = NULL)
  522. {
  523. /** http://www.flickr.com/services/api/flickr.photos.getRecent.html */
  524. if (is_array($extras)) {
  525. $extras = implode(",", $extras);
  526. }
  527. $this->request("flickr.photos.getRecent", array("extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
  528. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  529. }
  530. function photos_getSizes($photo_id)
  531. {
  532. /** http://www.flickr.com/services/api/flickr.photos.getSizes.html */
  533. $this->request("flickr.photos.getSizes", array("photo_id"=>$photo_id));
  534. return $this->parsed_response ? $this->parsed_response['sizes']['size'] : false;
  535. }
  536. 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)
  537. {
  538. /** http://www.flickr.com/services/api/flickr.photos.getUntagged.html */
  539. if (is_array($extras)) {
  540. $extras = implode(",", $extras);
  541. }
  542. $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));
  543. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  544. }
  545. function photos_getWithGeoData($args = NULL) {
  546. /** See the documentation included with the photos_search() function.
  547. * I'm using the same style of arguments for this function. The only
  548. * difference here is that this doesn't require any arguments. The
  549. * flickr.photos.search method requires at least one search parameter.
  550. */
  551. /** http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html */
  552. if (is_null($args)) {
  553. $args = array();
  554. }
  555. $this->request("flickr.photos.getWithGeoData", $args);
  556. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  557. }
  558. function photos_getWithoutGeoData($args = NULL) {
  559. /** See the documentation included with the photos_search() function.
  560. * I'm using the same style of arguments for this function. The only
  561. * difference here is that this doesn't require any arguments. The
  562. * flickr.photos.search method requires at least one search parameter.
  563. */
  564. /** http://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html */
  565. if (is_null($args)) {
  566. $args = array();
  567. }
  568. $this->request("flickr.photos.getWithoutGeoData", $args);
  569. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  570. }
  571. function photos_recentlyUpdated($min_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
  572. {
  573. /** http://www.flickr.com/services/api/flickr.photos.getUntagged.html */
  574. if (is_array($extras)) {
  575. $extras = implode(",", $extras);
  576. }
  577. $this->request("flickr.photos.recentlyUpdated", array("min_date"=>$min_date, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
  578. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  579. }
  580. function photos_removeTag($tag_id)
  581. {
  582. /** http://www.flickr.com/services/api/flickr.photos.removeTag.html */
  583. $this->request("flickr.photos.removeTag", array("tag_id"=>$tag_id), TRUE);
  584. return $this->parsed_response ? true : false;
  585. }
  586. function photos_search($args)
  587. {
  588. /** This function strays from the method of arguments that I've
  589. * used in the other functions for the fact that there are just
  590. * so many arguments to this API method. What you'll need to do
  591. * is pass an associative array to the function containing the
  592. * arguments you want to pass to the API. For example:
  593. * $photos = $f->photos_search(array("tags"=>"brown,cow", "tag_mode"=>"any"));
  594. * This will return photos tagged with either "brown" or "cow"
  595. * or both. See the API documentation (link below) for a full
  596. * list of arguments.
  597. */
  598. /** http://www.flickr.com/services/api/flickr.photos.search.html */
  599. $this->request("flickr.photos.search", $args);
  600. return $this->parsed_response ? $this->parsed_response['photos'] : false;
  601. }
  602. function photos_setContentType ($photo_id, $content_type) {
  603. /** http://www.flickr.com/services/api/flickr.photos.setContentType.html */
  604. return $this->call('flickr.photos.setContentType', array('photo_id' => $photo_id, 'content_type' => $content_type));
  605. }
  606. function photos_setDates($photo_id, $date_posted = NULL, $date_taken = NULL, $date_taken_granularity = NULL)
  607. {
  608. /** http://www.flickr.com/services/api/flickr.photos.setDates.html */
  609. $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);
  610. return $this->parsed_response ? true : false;
  611. }
  612. function photos_setMeta($photo_id, $title, $description)
  613. {
  614. /** http://www.flickr.com/services/api/flickr.photos.setMeta.html */
  615. $this->request("flickr.photos.setMeta", array("photo_id"=>$photo_id, "title"=>$title, "description"=>$description), TRUE);
  616. return $this->parsed_response ? true : false;
  617. }
  618. function photos_setPerms($photo_id, $is_public, $is_friend, $is_family, $perm_comment, $perm_addmeta)
  619. {
  620. /** http://www.flickr.com/services/api/flickr.photos.setPerms.html */
  621. $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);
  622. return $this->parsed_response ? true : false;
  623. }
  624. function photos_setSafetyLevel ($photo_id, $safety_level, $hidden = null) {
  625. /** http://www.flickr.com/services/api/flickr.photos.setSafetyLevel.html */
  626. return $this->call('flickr.photos.setSafetyLevel', array('photo_id' => $photo_id, 'safety_level' => $safety_level, 'hidden' => $hidden));
  627. }
  628. function photos_setTags($photo_id, $tags)
  629. {
  630. /** http://www.flickr.com/services/api/flickr.photos.setTags.html */
  631. $this->request("flickr.photos.setTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE);
  632. return $this->parsed_response ? true : false;
  633. }
  634. /** Photos - Comments Methods */
  635. function photos_comments_addComment($photo_id, $comment_text) {
  636. /** http://www.flickr.com/services/api/flickr.photos.comments.addComment.html */
  637. $this->request("flickr.photos.comments.addComment", array("photo_id" => $photo_id, "comment_text"=>$comment_text), TRUE);
  638. return $this->parsed_response ? $this->parsed_response['comment'] : false;
  639. }
  640. function photos_comments_deleteComment($comment_id) {
  641. /** http://www.flickr.com/services/api/flickr.photos.comments.deleteComment.html */
  642. $this->request("flickr.photos.comments.deleteComment", array("comment_id" => $comment_id), TRUE);
  643. return $this->parsed_response ? true : false;
  644. }
  645. function photos_comments_editComment($comment_id, $comment_text) {
  646. /** http://www.flickr.com/services/api/flickr.photos.comments.editComment.html */
  647. $this->request("flickr.photos.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE);
  648. return $this->parsed_response ? true : false;
  649. }
  650. function photos_comments_getList($photo_id)
  651. {
  652. /** http://www.flickr.com/services/api/flickr.photos.comments.getList.html */
  653. $this->request("flickr.photos.comments.getList", array("photo_id"=>$photo_id));
  654. return $this->parsed_response ? $this->parsed_response['comments'] : false;
  655. }
  656. /** Photos - Geo Methods */
  657. function photos_geo_getLocation($photo_id)
  658. {
  659. /** http://www.flickr.com/services/api/flickr.photos.geo.getLocation.html */
  660. $this->request("flickr.photos.geo.getLocation", array("photo_id"=>$photo_id));
  661. return $this->parsed_response ? $this->parsed_response['photo'] : false;
  662. }
  663. function photos_geo_getPerms($photo_id)
  664. {
  665. /** http://www.flickr.com/services/api/flickr.photos.geo.getPerms.html */
  666. $this->request("flickr.photos.geo.getPerms", array("photo_id"=>$photo_id));
  667. return $this->parsed_response ? $this->parsed_response['perms'] : false;
  668. }
  669. function photos_geo_removeLocation($photo_id)
  670. {
  671. /** http://www.flickr.com/services/api/flickr.photos.geo.removeLocation.html */
  672. $this->request("flickr.photos.geo.removeLocation", array("photo_id"=>$photo_id), TRUE);
  673. return $this->parsed_response ? true : false;
  674. }
  675. function photos_geo_setLocation($photo_id, $lat, $lon, $accuracy = NULL)
  676. {
  677. /** http://www.flickr.com/services/api/flickr.photos.geo.setLocation.html */
  678. $this->request("flickr.photos.geo.setLocation", array("photo_id"=>$photo_id, "lat"=>$lat, "lon"=>$lon, "accuracy"=>$accuracy), TRUE);
  679. return $this->parsed_response ? true : false;
  680. }
  681. function photos_geo_setPerms($photo_id, $is_public, $is_contact, $is_friend, $is_family)
  682. {
  683. /** http://www.flickr.com/services/api/flickr.photos.geo.setPerms.html */
  684. $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);
  685. return $this->parsed_response ? true : false;
  686. }
  687. /** Photos - Licenses Methods */
  688. function photos_licenses_getInfo()
  689. {
  690. /** http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html */
  691. $this->request("flickr.photos.licenses.getInfo");
  692. return $this->parsed_response ? $this->parsed_response['licenses']['license'] : false;
  693. }
  694. function photos_licenses_setLicense($photo_id, $license_id)
  695. {
  696. /** http://www.flickr.com/services/api/flickr.photos.licenses.setLicense.html */
  697. /** Requires Authentication */
  698. $this->request("flickr.photos.licenses.setLicense", array("photo_id"=>$photo_id, "license_id"=>$license_id), TRUE);
  699. return $this->parsed_response ? true : false;
  700. }
  701. /** Photos - Notes Methods */
  702. function photos_notes_add($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text)
  703. {
  704. /** http://www.flickr.com/services/api/flickr.photos.notes.add.html */
  705. $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);
  706. return $this->parsed_response ? $this->parsed_response['note'] : false;
  707. }
  708. function photos_notes_delete($note_id)
  709. {
  710. /** http://www.flickr.com/services/api/flickr.photos.notes.delete.html */
  711. $this->request("flickr.photos.notes.delete", array("note_id" => $note_id), TRUE);
  712. return $this->parsed_response ? true : false;
  713. }
  714. function photos_notes_edit($note_id, $note_x, $note_y, $note_w, $note_h, $note_text)
  715. {
  716. /** http://www.flickr.com/services/api/flickr.photos.notes.edit.html */
  717. $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);
  718. return $this->parsed_response ? true : false;
  719. }
  720. /** Photos - Transform Methods */
  721. function photos_transform_rotate($photo_id, $degrees)
  722. {
  723. /** http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */
  724. $this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE);
  725. return $this->parsed_response ? true : false;
  726. }
  727. /** Photos - Upload Methods */
  728. function photos_upload_checkTickets($tickets)
  729. {
  730. /** http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html */
  731. if (is_array($tickets)) {
  732. $tickets = implode(",", $tickets);
  733. }
  734. $this->request("flickr.photos.upload.checkTickets", array("tickets" => $tickets), TRUE);
  735. return $this->parsed_response ? $this->parsed_response['uploader']['ticket'] : false;
  736. }
  737. /** Photosets Methods */
  738. function photosets_addPhoto($photoset_id, $photo_id)
  739. {
  740. /** http://www.flickr.com/services/api/flickr.photosets.addPhoto.html */
  741. $this->request("flickr.photosets.addPhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE);
  742. return $this->parsed_response ? true : false;
  743. }
  744. function photosets_create($title, $description, $primary_photo_id)
  745. {
  746. /** http://www.flickr.com/services/api/flickr.photosets.create.html */
  747. $this->request("flickr.photosets.create", array("title" => $title, "primary_photo_id" => $primary_photo_id, "description" => $description), TRUE);
  748. return $this->parsed_response ? $this->parsed_response['photoset'] : false;
  749. }
  750. function photosets_delete($photoset_id)
  751. {
  752. /** http://www.flickr.com/services/api/flickr.photosets.delete.html */
  753. $this->request("flickr.photosets.delete", array("photoset_id" => $photoset_id), TRUE);
  754. return $this->parsed_response ? true : false;
  755. }
  756. function photosets_editMeta($photoset_id, $title, $description = NULL)
  757. {
  758. /** http://www.flickr.com/services/api/flickr.photosets.editMeta.html */
  759. $this->request("flickr.photosets.editMeta", array("photoset_id" => $photoset_id, "title" => $title, "description" => $description), TRUE);
  760. return $this->parsed_response ? true : false;
  761. }
  762. function photosets_editPhotos($photoset_id, $primary_photo_id, $photo_ids)
  763. {
  764. /** http://www.flickr.com/services/api/flickr.photosets.editPhotos.html */
  765. $this->request("flickr.photosets.editPhotos", array("photoset_id" => $photoset_id, "primary_photo_id" => $primary_photo_id, "photo_ids" => $photo_ids), TRUE);
  766. return $this->parsed_response ? true : false;
  767. }
  768. function photosets_getContext($photo_id, $photoset_id)
  769. {
  770. /** http://www.flickr.com/services/api/flickr.photosets.getContext.html */
  771. $this->request("flickr.photosets.getContext", array("photo_id" => $photo_id, "photoset_id" => $photoset_id));
  772. return $this->parsed_response ? $this->parsed_response : false;
  773. }
  774. function photosets_getInfo($photoset_id)
  775. {
  776. /** http://www.flickr.com/services/api/flickr.photosets.getInfo.html */
  777. $this->request("flickr.photosets.getInfo", array("photoset_id" => $photoset_id));
  778. return $this->parsed_response ? $this->parsed_response['photoset'] : false;
  779. }
  780. function photosets_getList($user_id = NULL)
  781. {
  782. /** http://www.flickr.com/services/api/flickr.photosets.getList.html */
  783. $this->request("flickr.photosets.getList", array("user_id" => $user_id));
  784. return $this->parsed_response ? $this->parsed_response['photosets'] : false;
  785. }
  786. function photosets_getPhotos($photoset_id, $extras = NULL, $privacy_filter = NULL, $per_page = NULL, $page = NULL)
  787. {
  788. /** http://www.flickr.com/services/api/flickr.photosets.getPhotos.html */
  789. $this->request("flickr.photosets.getPhotos", array("photoset_id" => $photoset_id, "extras" => $extras, "privacy_filter" => $privacy_filter, "per_page" => $per_page, "page" => $page));
  790. return $this->parsed_response ? $this->parsed_response['photoset'] : false;
  791. }
  792. function photosets_orderSets($photoset_ids)
  793. {
  794. /** http://www.flickr.com/services/api/flickr.photosets.orderSets.html */
  795. if (is_array($photoset_ids)) {
  796. $photoset_ids = implode(",", $photoset_ids);
  797. }
  798. $this->request("flickr.photosets.orderSets", array("photoset_ids" => $photoset_ids), TRUE);
  799. return $this->parsed_response ? true : false;
  800. }
  801. function photosets_removePhoto($photoset_id, $photo_id)
  802. {
  803. /** http://www.flickr.com/services/api/flickr.photosets.removePhoto.html */
  804. $this->request("flickr.photosets.removePhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE);
  805. return $this->parsed_response ? true : false;
  806. }
  807. /** Photosets Comments Methods */
  808. function photosets_comments_addComment($photoset_id, $comment_text) {
  809. /** http://www.flickr.com/services/api/flickr.photosets.comments.addComment.html */
  810. $this->request("flickr.photosets.comments.addComment", array("photoset_id" => $photoset_id, "comment_text"=>$comment_text), TRUE);
  811. return $this->parsed_response ? $this->parsed_response['comment'] : false;
  812. }
  813. function photosets_comments_deleteComment($comment_id) {
  814. /** http://www.flickr.com/services/api/flickr.photosets.comments.deleteComment.html */
  815. $this->request("flickr.photosets.comments.deleteComment", array("comment_id" => $comment_id), TRUE);
  816. return $this->parsed_response ? true : false;
  817. }
  818. function photosets_comments_editComment($comment_id, $comment_text) {
  819. /** http://www.flickr.com/services/api/flickr.photosets.comments.editComment.html */
  820. $this->request("flickr.photosets.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE);
  821. return $this->parsed_response ? true : false;
  822. }
  823. function photosets_comments_getList($photoset_id)
  824. {
  825. /** http://www.flickr.com/services/api/flickr.photosets.comments.getList.html */
  826. $this->request("flickr.photosets.comments.getList", array("photoset_id"=>$photoset_id));
  827. return $this->parsed_response ? $this->parsed_response['comments'] : false;
  828. }
  829. /** Places Methods */
  830. function places_resolvePlaceId ($place_id) {
  831. /** http://www.flickr.com/services/api/flickr.places.resolvePlaceId.html */
  832. $rsp = $this->call('flickr.places.resolvePlaceId', array('place_id' => $place_id));
  833. return $rsp ? $rsp['location'] : $rsp;
  834. }
  835. function places_resolvePlaceURL ($url) {
  836. /** http://www.flickr.com/services/api/flickr.places.resolvePlaceURL.html */
  837. $rsp = $this->call('flickr.places.resolvePlaceURL', array('url' => $url));
  838. return $rsp ? $rsp['location'] : $rsp;
  839. }
  840. /** Prefs Methods */
  841. function prefs_getContentType () {
  842. /** http://www.flickr.com/services/api/flickr.prefs.getContentType.html */
  843. $rsp = $this->call('flickr.prefs.getContentType', array());
  844. return $rsp ? $rsp['person'] : $rsp;
  845. }
  846. function prefs_getHidden () {
  847. /** http://www.flickr.com/services/api/flickr.prefs.getHidden.html */
  848. $rsp = $this->call('flickr.prefs.getHidden', array());
  849. return $rsp ? $rsp['person'] : $rsp;
  850. }
  851. function prefs_getPrivacy () {
  852. /** http://www.flickr.com/services/api/flickr.prefs.getPrivacy.html */
  853. $rsp = $this->call('flickr.prefs.getPrivacy', array());
  854. return $rsp ? $rsp['person'] : $rsp;
  855. }
  856. function prefs_getSafetyLevel () {
  857. /** http://www.flickr.com/services/api/flickr.prefs.getSafetyLevel.html */
  858. $rsp = $this->call('flickr.prefs.getSafetyLevel', array());
  859. return $rsp ? $rsp['person'] : $rsp;
  860. }
  861. /** Reflection Methods */
  862. function reflection_getMethodInfo($method_name)
  863. {
  864. /** http://www.flickr.com/services/api/flickr.reflection.getMethodInfo.html */
  865. $this->request("flickr.reflection.getMethodInfo", array("method_name" => $method_name));
  866. return $this->parsed_response ? $this->parsed_response : false;
  867. }
  868. function reflection_getMethods()
  869. {
  870. /** http://www.flickr.com/services/api/flickr.reflection.getMethods.html */
  871. $this->request("flickr.reflection.getMethods");
  872. return $this->parsed_response ? $this->parsed_response['methods']['method'] : false;
  873. }
  874. /** Tags Methods */
  875. function tags_getHotList($period = NULL, $count = NULL)
  876. {
  877. /** http://www.flickr.com/services/api/flickr.tags.getHotList.html */
  878. $this->request("flickr.tags.getHotList", array("period" => $period, "count" => $count));
  879. return $this->parsed_response ? $this->parsed_response['hottags'] : false;
  880. }
  881. function tags_getListPhoto($photo_id)
  882. {
  883. /** http://www.flickr.com/services/api/flickr.tags.getListPhoto.html */
  884. $this->request("flickr.tags.getListPhoto", array("photo_id" => $photo_id));
  885. return $this->parsed_response ? $this->parsed_response['photo']['tags']['tag'] : false;
  886. }
  887. function tags_getListUser($user_id = NULL)
  888. {
  889. /** http://www.flickr.com/services/api/flickr.tags.getListUser.html */
  890. $this->request("flickr.tags.getListUser", array("user_id" => $user_id));
  891. return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false;
  892. }
  893. function tags_getListUserPopular($user_id = NULL, $count = NULL)
  894. {
  895. /** http://www.flickr.com/services/api/flickr.tags.getListUserPopular.html */
  896. $this->request("flickr.tags.getListUserPopular", array("user_id" => $user_id, "count" => $count));
  897. return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false;
  898. }
  899. function tags_getListUserRaw($tag)
  900. {
  901. /** http://www.flickr.com/services/api/flickr.tags.getListUserRaw.html */
  902. $this->request("flickr.tags.getListUserRaw", array("tag" => $tag));
  903. return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'][0]['raw'] : false;
  904. }
  905. function tags_getRelated($tag)
  906. {
  907. /** http://www.flickr.com/services/api/flickr.tags.getRelated.html */
  908. $this->request("flickr.tags.getRelated", array("tag" => $tag));
  909. return $this->parsed_response ? $this->parsed_response['tags'] : false;
  910. }
  911. function test_echo($args = array())
  912. {
  913. /** http://www.flickr.com/services/api/flickr.test.echo.html */
  914. $this->request("flickr.test.echo", $args);
  915. return $this->parsed_response ? $this->parsed_response : false;
  916. }
  917. function test_login()
  918. {
  919. /** http://www.flickr.com/services/api/flickr.test.login.html */
  920. $this->request("flickr.test.login");
  921. return $this->parsed_response ? $this->parsed_response['user'] : false;
  922. }
  923. function urls_getGroup($group_id)
  924. {
  925. /** http://www.flickr.com/services/api/flickr.urls.getGroup.html */
  926. $this->request("flickr.urls.getGroup", array("group_id"=>$group_id));
  927. return $this->parsed_response ? $this->parsed_response['group']['url'] : false;
  928. }
  929. function urls_getUserPhotos($user_id = NULL)
  930. {
  931. /** http://www.flickr.com/services/api/flickr.urls.getUserPhotos.html */
  932. $this->request("flickr.urls.getUserPhotos", array("user_id"=>$user_id));
  933. return $this->parsed_response ? $this->parsed_response['user']['url'] : false;
  934. }
  935. function urls_getUserProfile($user_id = NULL)
  936. {
  937. /** http://www.flickr.com/services/api/flickr.urls.getUserProfile.html */
  938. $this->request("flickr.urls.getUserProfile", array("user_id"=>$user_id));
  939. return $this->parsed_response ? $this->parsed_response['user']['url'] : false;
  940. }
  941. function urls_lookupGroup($url)
  942. {
  943. /** http://www.flickr.com/services/api/flickr.urls.lookupGroup.html */
  944. $this->request("flickr.urls.lookupGroup", array("url"=>$url));
  945. return $this->parsed_response ? $this->parsed_response['group'] : false;
  946. }
  947. function urls_lookupUser($url)
  948. {
  949. /** http://www.flickr.com/services/api/flickr.photos.notes.edit.html */
  950. $this->request("flickr.urls.lookupUser", array("url"=>$url));
  951. return $this->parsed_response ? $this->parsed_response['user'] : false;
  952. }
  953. /**
  954. * Upload a photo from Moodle file pool to Flickr
  955. *
  956. * Optional meta information are title, description, tags, is_public, is_friend, is_family, safety_level,

Large files files are truncated, but you can click here to view the full file