View source
<?php
if (!class_exists('phpFlickr')) {
if (session_id() == "") {
@session_start();
}
class phpFlickr {
var $api_key;
var $secret;
var $rest_endpoint = 'http://api.flickr.com/services/rest/';
var $upload_endpoint = 'http://api.flickr.com/services/upload/';
var $replace_endpoint = 'http://api.flickr.com/services/replace/';
var $req;
var $response;
var $parsed_response;
var $cache = false;
var $cache_db = null;
var $cache_table = null;
var $cache_dir = null;
var $cache_expire = null;
var $cache_key = null;
var $last_request = null;
var $die_on_error;
var $error_code;
var $error_msg;
var $token;
var $php_version;
var $custom_post = null, $custom_cache_get = null, $custom_cache_set = null;
var $max_cache_rows = 1000;
function phpFlickr($api_key, $secret = NULL, $die_on_error = false) {
$this->api_key = $api_key;
$this->secret = $secret;
$this->die_on_error = $die_on_error;
$this->service = "flickr";
$this->php_version = explode("-", phpversion());
$this->php_version = explode(".", $this->php_version[0]);
}
function enableCache($type, $connection, $cache_expire = 600, $table = 'flickr_cache') {
if ($type == 'db') {
if (preg_match('|mysql://([^:]*):([^@]*)@([^/]*)/(.*)|', $connection, $matches)) {
$db = mysql_connect($matches[3], $matches[1], $matches[2]);
mysql_select_db($matches[4], $db);
mysql_query("\n\t\t\t\t\t\tCREATE TABLE IF NOT EXISTS `{$table}` (\n\t\t\t\t\t\t\t`request` CHAR( 35 ) NOT NULL ,\n\t\t\t\t\t\t\t`response` MEDIUMTEXT NOT NULL ,\n\t\t\t\t\t\t\t`expiration` DATETIME NOT NULL ,\n\t\t\t\t\t\t\tINDEX ( `request` )\n\t\t\t\t\t\t) TYPE = MYISAM\n\t\t\t\t\t", $db);
$result = mysql_query("SELECT COUNT(*) FROM {$table}", $db);
$result = mysql_fetch_row($result);
if ($result[0] > $this->max_cache_rows) {
mysql_query("DELETE FROM {$table} WHERE expiration < DATE_SUB(NOW(), INTERVAL {$cache_expire} second)", $db);
mysql_query('OPTIMIZE TABLE ' . $this->cache_table, $db);
}
$this->cache = 'db';
$this->cache_db = $db;
$this->cache_table = $table;
}
}
elseif ($type == 'fs') {
$this->cache = 'fs';
$connection = realpath($connection);
$this->cache_dir = $connection;
if ($dir = opendir($this->cache_dir)) {
while ($file = readdir($dir)) {
if (substr($file, -6) == '.cache' && filemtime($this->cache_dir . '/' . $file) + $cache_expire < time()) {
unlink($this->cache_dir . '/' . $file);
}
}
}
}
elseif ($type == 'custom') {
$this->cache = "custom";
$this->custom_cache_get = $connection[0];
$this->custom_cache_set = $connection[1];
}
$this->cache_expire = $cache_expire;
}
function getCached($request) {
foreach ($request as $key => $value) {
if (empty($value)) {
unset($request[$key]);
}
else {
$request[$key] = (string) $request[$key];
}
}
$reqhash = md5(serialize($request));
$this->cache_key = $reqhash;
$this->cache_request = $request;
if ($this->cache == 'db') {
$result = mysql_query("SELECT response FROM " . $this->cache_table . " WHERE request = '" . $reqhash . "' AND DATE_SUB(NOW(), INTERVAL " . (int) $this->cache_expire . " SECOND) < expiration", $this->cache_db);
if (mysql_num_rows($result)) {
$result = mysql_fetch_assoc($result);
return $result['response'];
}
else {
return false;
}
}
elseif ($this->cache == 'fs') {
$file = $this->cache_dir . '/' . $reqhash . '.cache';
if (file_exists($file)) {
if ($this->php_version[0] > 4 || $this->php_version[0] == 4 && $this->php_version[1] >= 3) {
return file_get_contents($file);
}
else {
return implode('', file($file));
}
}
}
elseif ($this->cache == 'custom') {
return call_user_func_array($this->custom_cache_get, array(
$reqhash,
));
}
return false;
}
function cache($request, $response) {
unset($request['api_sig']);
foreach ($request as $key => $value) {
if (empty($value)) {
unset($request[$key]);
}
else {
$request[$key] = (string) $request[$key];
}
}
$reqhash = md5(serialize($request));
if ($this->cache == 'db') {
$result = mysql_query("SELECT COUNT(*) FROM " . $this->cache_table . " WHERE request = '" . $reqhash . "'", $this->cache_db);
$result = mysql_fetch_row($result);
if ($result[0]) {
$sql = "UPDATE " . $this->cache_table . " SET response = '" . str_replace("'", "''", $response) . "', expiration = '" . strftime("%Y-%m-%d %H:%M:%S") . "' WHERE request = '" . $reqhash . "'";
mysql_query($sql, $this->cache_db);
}
else {
$sql = "INSERT INTO " . $this->cache_table . " (request, response, expiration) VALUES ('{$reqhash}', '" . str_replace("'", "''", $response) . "', '" . strftime("%Y-%m-%d %H:%M:%S") . "')";
mysql_query($sql, $this->cache_db);
}
}
elseif ($this->cache == "fs") {
$file = $this->cache_dir . "/" . $reqhash . ".cache";
$fstream = fopen($file, "w");
$result = fwrite($fstream, $response);
fclose($fstream);
return $result;
}
elseif ($this->cache == "custom") {
return call_user_func_array($this->custom_cache_set, array(
$reqhash,
$response,
$this->cache_expire,
));
}
return false;
}
function setCustomPost($function) {
$this->custom_post = $function;
}
function post($data, $type = null) {
if (is_null($type)) {
$url = $this->rest_endpoint;
}
if (!is_null($this->custom_post)) {
return call_user_func($this->custom_post, $url, $data);
}
if (!preg_match("|http://(.*?)(/.*)|", $url, $matches)) {
die('There was some problem figuring out your endpoint');
}
if (function_exists('curl_init')) {
$curl = curl_init($this->rest_endpoint);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
}
else {
foreach ($data as $key => $value) {
$data[$key] = $key . '=' . urlencode($value);
}
$data = implode('&', $data);
$fp = @pfsockopen($matches[1], 80);
if (!$fp) {
die('Could not connect to the web service');
}
fputs($fp, 'POST ' . $matches[2] . " HTTP/1.1\n");
fputs($fp, 'Host: ' . $matches[1] . "\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data . "\n\n");
$response = "";
while (!feof($fp)) {
$response .= fgets($fp, 1024);
}
fclose($fp);
$chunked = false;
$http_status = trim(substr($response, 0, strpos($response, "\n")));
if ($http_status != 'HTTP/1.1 200 OK') {
die('The web service endpoint returned a "' . $http_status . '" response');
}
if (strpos($response, 'Transfer-Encoding: chunked') !== false) {
$temp = trim(strstr($response, "\r\n\r\n"));
$response = '';
$length = trim(substr($temp, 0, strpos($temp, "\r")));
while (trim($temp) != "0" && ($length = trim(substr($temp, 0, strpos($temp, "\r")))) != "0") {
$response .= trim(substr($temp, strlen($length) + 2, hexdec($length)));
$temp = trim(substr($temp, strlen($length) + 2 + hexdec($length)));
}
}
elseif (strpos($response, 'HTTP/1.1 200 OK') !== false) {
$response = trim(strstr($response, "\r\n\r\n"));
}
}
return $response;
}
function request($command, $args = array(), $nocache = false) {
if (substr($command, 0, 7) != "flickr.") {
$command = "flickr." . $command;
}
$args = array_merge(array(
"method" => $command,
"format" => "php_serial",
"api_key" => $this->api_key,
), $args);
if (!empty($this->token)) {
$args = array_merge($args, array(
"auth_token" => $this->token,
));
}
elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
$args = array_merge($args, array(
"auth_token" => $_SESSION['phpFlickr_auth_token'],
));
}
ksort($args);
$auth_sig = "";
$this->last_request = $args;
if (!($this->response = $this
->getCached($args)) || $nocache) {
foreach ($args as $key => $data) {
if (is_null($data)) {
unset($args[$key]);
continue;
}
$auth_sig .= $key . $data;
}
if (!empty($this->secret)) {
$api_sig = md5($this->secret . $auth_sig);
$args['api_sig'] = $api_sig;
}
$this->response = $this
->post($args);
$this
->cache($args, $this->response);
}
$this->parsed_response = $this
->clean_text_nodes(unserialize($this->response));
if ($this->parsed_response['stat'] == 'fail') {
if ($this->die_on_error) {
die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
}
else {
$this->error_code = $this->parsed_response['code'];
$this->error_msg = $this->parsed_response['message'];
$this->parsed_response = false;
}
}
else {
$this->error_code = false;
$this->error_msg = false;
}
return $this->response;
}
function clean_text_nodes($arr) {
if (!is_array($arr)) {
return $arr;
}
elseif (count($arr) == 0) {
return $arr;
}
elseif (count($arr) == 1 && array_key_exists('_content', $arr)) {
return $arr['_content'];
}
else {
foreach ($arr as $key => $element) {
$arr[$key] = $this
->clean_text_nodes($element);
}
return $arr;
}
}
function setToken($token) {
$this->token = $token;
}
function setProxy($server, $port) {
$this->req
->setProxy($server, $port);
}
function getErrorCode() {
return $this->error_code;
}
function getErrorMsg() {
return $this->error_msg;
}
function buildPhotoURL($photo, $size = "Medium") {
$sizes = array(
"square" => "_s",
"thumbnail" => "_t",
"small" => "_m",
"medium" => "",
"large" => "_b",
"original" => "_o",
);
$size = strtolower($size);
if (!array_key_exists($size, $sizes)) {
$size = "medium";
}
if ($size == "original") {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['originalsecret'] . "_o" . "." . $photo['originalformat'];
}
else {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes[$size] . ".jpg";
}
return $url;
}
function getFriendlyGeodata($lat, $lon) {
return unserialize(file_get_contents('http://phpflickr.com/geodata/?format=php&lat=' . $lat . '&lon=' . $lon));
}
function sync_upload($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) {
if (function_exists('curl_init')) {
$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,
);
if (!empty($this->token)) {
$args = array_merge($args, array(
"auth_token" => $this->token,
));
}
elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
$args = array_merge($args, array(
"auth_token" => $_SESSION['phpFlickr_auth_token'],
));
}
ksort($args);
$auth_sig = "";
foreach ($args as $key => $data) {
if (is_null($data)) {
unset($args[$key]);
}
else {
$auth_sig .= $key . $data;
}
}
if (!empty($this->secret)) {
$api_sig = md5($this->secret . $auth_sig);
$args["api_sig"] = $api_sig;
}
$photo = realpath($photo);
$args['photo'] = '@' . $photo;
$curl = curl_init($this->upload_endpoint);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $args);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$this->response = $response;
curl_close($curl);
$rsp = explode("\n", $response);
foreach ($rsp as $line) {
if (ereg('<err code="([0-9]+)" msg="(.*)"', $line, $match)) {
if ($this->die_on_error) {
die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}");
}
else {
$this->error_code = $match[1];
$this->error_msg = $match[2];
$this->parsed_response = false;
return false;
}
}
elseif (ereg("<photoid>(.*)</photoid>", $line, $match)) {
$this->error_code = false;
$this->error_msg = false;
return $match[1];
}
}
}
else {
die("Sorry, your server must support CURL in order to upload files");
}
}
function async_upload($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) {
if (function_exists('curl_init')) {
$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,
);
if (!empty($this->token)) {
$args = array_merge($args, array(
"auth_token" => $this->token,
));
}
elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
$args = array_merge($args, array(
"auth_token" => $_SESSION['phpFlickr_auth_token'],
));
}
ksort($args);
$auth_sig = "";
foreach ($args as $key => $data) {
if (is_null($data)) {
unset($args[$key]);
}
else {
$auth_sig .= $key . $data;
}
}
if (!empty($this->secret)) {
$api_sig = md5($this->secret . $auth_sig);
$args["api_sig"] = $api_sig;
}
$photo = realpath($photo);
$args['photo'] = '@' . $photo;
$curl = curl_init($this->upload_endpoint);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $args);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$this->response = $response;
curl_close($curl);
$rsp = explode("\n", $response);
foreach ($rsp as $line) {
if (ereg('<err code="([0-9]+)" msg="(.*)"', $line, $match)) {
if ($this->die_on_error) {
die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}");
}
else {
$this->error_code = $match[1];
$this->error_msg = $match[2];
$this->parsed_response = false;
return false;
}
}
elseif (ereg("<ticketid>(.*)</", $line, $match)) {
$this->error_code = false;
$this->error_msg = false;
return $match[1];
}
}
}
else {
die("Sorry, your server must support CURL in order to upload files");
}
}
function replace($photo, $photo_id, $async = null) {
if (function_exists('curl_init')) {
$args = array(
"api_key" => $this->api_key,
"photo_id" => $photo_id,
"async" => $async,
);
if (!empty($this->token)) {
$args = array_merge($args, array(
"auth_token" => $this->token,
));
}
elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
$args = array_merge($args, array(
"auth_token" => $_SESSION['phpFlickr_auth_token'],
));
}
ksort($args);
$auth_sig = "";
foreach ($args as $key => $data) {
if (is_null($data)) {
unset($args[$key]);
}
else {
$auth_sig .= $key . $data;
}
}
if (!empty($this->secret)) {
$api_sig = md5($this->secret . $auth_sig);
$args["api_sig"] = $api_sig;
}
$photo = realpath($photo);
$args['photo'] = '@' . $photo;
$curl = curl_init($this->replace_endpoint);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $args);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$this->response = $response;
curl_close($curl);
if ($async == 1) {
$find = 'ticketid';
}
else {
$find = 'photoid';
}
$rsp = explode("\n", $response);
foreach ($rsp as $line) {
if (ereg('<err code="([0-9]+)" msg="(.*)"', $line, $match)) {
if ($this->die_on_error) {
die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}");
}
else {
$this->error_code = $match[1];
$this->error_msg = $match[2];
$this->parsed_response = false;
return false;
}
}
elseif (ereg("<" . $find . ">(.*)</", $line, $match)) {
$this->error_code = false;
$this->error_msg = false;
return $match[1];
}
}
}
else {
die("Sorry, your server must support CURL in order to upload files");
}
}
function auth($perms = "read", $remember_uri = true) {
if (empty($_SESSION['phpFlickr_auth_token']) && empty($this->token)) {
if ($remember_uri === true) {
session_register('phpFlickr_auth_redirect');
$_SESSION['phpFlickr_auth_redirect'] = $_SERVER['REQUEST_URI'];
}
elseif ($remember_uri !== false) {
session_register('phpFlickr_auth_redirect');
$_SESSION['phpFlickr_auth_redirect'] = $remember_uri;
}
$api_sig = md5($this->secret . "api_key" . $this->api_key . "perms" . $perms);
if ($this->service == "23") {
header("Location: http://www.23hq.com/services/auth/?api_key=" . $this->api_key . "&perms=" . $perms . "&api_sig=" . $api_sig);
}
else {
header("Location: http://www.flickr.com/services/auth/?api_key=" . $this->api_key . "&perms=" . $perms . "&api_sig=" . $api_sig);
}
exit;
}
else {
$tmp = $this->die_on_error;
$this->die_on_error = false;
$rsp = $this
->auth_checkToken();
if ($this->error_code !== false) {
unset($_SESSION['phpFlickr_auth_token']);
$this
->auth($perms, $remember_uri);
}
$this->die_on_error = $tmp;
return $rsp['perms'];
}
}
function call($method, $arguments) {
foreach ($arguments as $key => $value) {
if (is_null($value)) {
unset($arguments[$key]);
}
}
$this
->request($method, $arguments);
return $this->parsed_response ? $this->parsed_response : false;
}
function activity_userComments($per_page = NULL, $page = NULL) {
$this
->request('flickr.activity.userComments', array(
"per_page" => $per_page,
"page" => $page,
));
return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
}
function activity_userPhotos($timeframe = NULL, $per_page = NULL, $page = NULL) {
$this
->request('flickr.activity.userPhotos', array(
"timeframe" => $timeframe,
"per_page" => $per_page,
"page" => $page,
));
return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
}
function auth_checkToken() {
$this
->request('flickr.auth.checkToken');
return $this->parsed_response ? $this->parsed_response['auth'] : false;
}
function auth_getFrob() {
$this
->request('flickr.auth.getFrob');
return $this->parsed_response ? $this->parsed_response['frob'] : false;
}
function auth_getFullToken($mini_token) {
$this
->request('flickr.auth.getFullToken', array(
'mini_token' => $mini_token,
));
return $this->parsed_response ? $this->parsed_response['auth'] : false;
}
function auth_getToken($frob) {
$this
->request('flickr.auth.getToken', array(
'frob' => $frob,
));
session_register('phpFlickr_auth_token');
$_SESSION['phpFlickr_auth_token'] = $this->parsed_response['auth']['token'];
return $this->parsed_response ? $this->parsed_response['auth'] : false;
}
function blogs_getList($service = NULL) {
$rsp = $this
->call('flickr.blogs.getList', array(
'service' => $service,
));
return $rsp['blogs']['blog'];
}
function blogs_getServices() {
return $this
->call('flickr.blogs.getServices', array());
}
function blogs_postPhoto($blog_id = NULL, $photo_id, $title, $description, $blog_password = NULL, $service = NULL) {
return $this
->call('flickr.blogs.postPhoto', array(
'blog_id' => $blog_id,
'photo_id' => $photo_id,
'title' => $title,
'description' => $description,
'blog_password' => $blog_password,
'service' => $service,
));
}
function collections_getInfo($collection_id) {
return $this
->call('flickr.collections.getInfo', array(
'collection_id' => $collection_id,
));
}
function collections_getTree($collection_id = NULL, $user_id = NULL) {
return $this
->call('flickr.collections.getTree', array(
'collection_id' => $collection_id,
'user_id' => $user_id,
));
}
function commons_getInstitutions() {
return $this
->call('flickr.commons.getInstitutions', array());
}
function contacts_getList($filter = NULL, $page = NULL, $per_page = NULL) {
$this
->request('flickr.contacts.getList', array(
'filter' => $filter,
'page' => $page,
'per_page' => $per_page,
));
return $this->parsed_response ? $this->parsed_response['contacts'] : false;
}
function contacts_getPublicList($user_id, $page = NULL, $per_page = NULL) {
$this
->request('flickr.contacts.getPublicList', array(
'user_id' => $user_id,
'page' => $page,
'per_page' => $per_page,
));
return $this->parsed_response ? $this->parsed_response['contacts'] : false;
}
function contacts_getListRecentlyUploaded($date_lastupload = NULL, $filter = NULL) {
return $this
->call('flickr.contacts.getListRecentlyUploaded', array(
'date_lastupload' => $date_lastupload,
'filter' => $filter,
));
}
function favorites_add($photo_id) {
$this
->request('flickr.favorites.add', array(
'photo_id' => $photo_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function favorites_getList($user_id = NULL, $min_fave_date = NULL, $max_fave_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.favorites.getList', array(
'user_id' => $user_id,
'min_fave_date' => $min_fave_date,
'max_fave_date' => $max_fave_date,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function favorites_getPublicList($user_id, $min_fave_date = NULL, $max_fave_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.favorites.getPublicList', array(
'user_id' => $user_id,
'min_fave_date' => $min_fave_date,
'max_fave_date' => $max_fave_date,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function favorites_remove($photo_id) {
$this
->request("flickr.favorites.remove", array(
"photo_id" => $photo_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function galleries_addPhoto($gallery_id, $photo_id, $comment = NULL) {
return $this
->call('flickr.galleries.addPhoto', array(
'gallery_id' => $gallery_id,
'photo_id' => $photo_id,
'comment' => $comment,
));
}
function galleries_create($title, $description, $primary_photo_id = NULL) {
return $this
->call('flickr.galleries.create', array(
'title' => $title,
'description' => $description,
'primary_photo_id' => $primary_photo_id,
));
}
function galleries_editMeta($gallery_id, $title, $description = NULL) {
return $this
->call('flickr.galleries.editMeta', array(
'gallery_id' => $gallery_id,
'title' => $title,
'description' => $description,
));
}
function galleries_editPhoto($gallery_id, $photo_id, $comment) {
return $this
->call('flickr.galleries.editPhoto', array(
'gallery_id' => $gallery_id,
'photo_id' => $photo_id,
'comment' => $comment,
));
}
function galleries_editPhotos($gallery_id, $primary_photo_id, $photo_ids) {
return $this
->call('flickr.galleries.editPhotos', array(
'gallery_id' => $gallery_id,
'primary_photo_id' => $primary_photo_id,
'photo_ids' => $photo_ids,
));
}
function galleries_getInfo($gallery_id) {
return $this
->call('flickr.galleries.getInfo', array(
'gallery_id' => $gallery_id,
));
}
function galleries_getList($user_id, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.galleries.getList', array(
'user_id' => $user_id,
'per_page' => $per_page,
'page' => $page,
));
}
function galleries_getListForPhoto($photo_id, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.galleries.getListForPhoto', array(
'photo_id' => $photo_id,
'per_page' => $per_page,
'page' => $page,
));
}
function galleries_getPhotos($gallery_id, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.galleries.getPhotos', array(
'gallery_id' => $gallery_id,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function groups_browse($cat_id = NULL) {
$this
->request("flickr.groups.browse", array(
"cat_id" => $cat_id,
));
return $this->parsed_response ? $this->parsed_response['category'] : false;
}
function groups_getInfo($group_id, $lang = NULL) {
return $this
->call('flickr.groups.getInfo', array(
'group_id' => $group_id,
'lang' => $lang,
));
}
function groups_search($text, $per_page = NULL, $page = NULL) {
$this
->request("flickr.groups.search", array(
"text" => $text,
"per_page" => $per_page,
"page" => $page,
));
return $this->parsed_response ? $this->parsed_response['groups'] : false;
}
function groups_members_getList($group_id, $membertypes = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.groups.members.getList', array(
'group_id' => $group_id,
'membertypes' => $membertypes,
'per_page' => $per_page,
'page' => $page,
));
}
function groups_pools_add($photo_id, $group_id) {
$this
->request("flickr.groups.pools.add", array(
"photo_id" => $photo_id,
"group_id" => $group_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function groups_pools_getContext($photo_id, $group_id) {
$this
->request("flickr.groups.pools.getContext", array(
"photo_id" => $photo_id,
"group_id" => $group_id,
));
return $this->parsed_response ? $this->parsed_response : false;
}
function groups_pools_getGroups($page = NULL, $per_page = NULL) {
$this
->request("flickr.groups.pools.getGroups", array(
'page' => $page,
'per_page' => $per_page,
));
return $this->parsed_response ? $this->parsed_response['groups'] : false;
}
function groups_pools_getPhotos($group_id, $tags = NULL, $user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$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,
));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function groups_pools_remove($photo_id, $group_id) {
$this
->request("flickr.groups.pools.remove", array(
"photo_id" => $photo_id,
"group_id" => $group_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function interestingness_getList($date = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this
->request("flickr.interestingness.getList", array(
"date" => $date,
"extras" => $extras,
"per_page" => $per_page,
"page" => $page,
));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function machinetags_getNamespaces($predicate = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.machinetags.getNamespaces', array(
'predicate' => $predicate,
'per_page' => $per_page,
'page' => $page,
));
}
function machinetags_getPairs($namespace = NULL, $predicate = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.machinetags.getPairs', array(
'namespace' => $namespace,
'predicate' => $predicate,
'per_page' => $per_page,
'page' => $page,
));
}
function machinetags_getPredicates($namespace = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.machinetags.getPredicates', array(
'namespace' => $namespace,
'per_page' => $per_page,
'page' => $page,
));
}
function machinetags_getRecentValues($namespace = NULL, $predicate = NULL, $added_since = NULL) {
return $this
->call('flickr.machinetags.getRecentValues', array(
'namespace' => $namespace,
'predicate' => $predicate,
'added_since' => $added_since,
));
}
function machinetags_getValues($namespace, $predicate, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.machinetags.getValues', array(
'namespace' => $namespace,
'predicate' => $predicate,
'per_page' => $per_page,
'page' => $page,
));
}
function panda_getList() {
return $this
->call('flickr.panda.getList', array());
}
function panda_getPhotos($panda_name, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.panda.getPhotos', array(
'panda_name' => $panda_name,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function people_findByEmail($find_email) {
$this
->request("flickr.people.findByEmail", array(
"find_email" => $find_email,
));
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
function people_findByUsername($username) {
$this
->request("flickr.people.findByUsername", array(
"username" => $username,
));
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
function people_getInfo($user_id) {
$this
->request("flickr.people.getInfo", array(
"user_id" => $user_id,
));
return $this->parsed_response ? $this->parsed_response['person'] : false;
}
function people_getPhotos($user_id, $args = array()) {
return $this
->call('flickr.people.getPhotos', array_merge(array(
'user_id' => $user_id,
), $args));
}
function people_getPhotosOf($user_id, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.people.getPhotosOf', array(
'user_id' => $user_id,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function people_getPublicGroups($user_id) {
$this
->request("flickr.people.getPublicGroups", array(
"user_id" => $user_id,
));
return $this->parsed_response ? $this->parsed_response['groups']['group'] : false;
}
function people_getPublicPhotos($user_id, $safe_search = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.people.getPublicPhotos', array(
'user_id' => $user_id,
'safe_search' => $safe_search,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function people_getUploadStatus() {
$this
->request("flickr.people.getUploadStatus");
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
function photos_addTags($photo_id, $tags) {
$this
->request("flickr.photos.addTags", array(
"photo_id" => $photo_id,
"tags" => $tags,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_delete($photo_id) {
$this
->request("flickr.photos.delete", array(
"photo_id" => $photo_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_getAllContexts($photo_id) {
$this
->request("flickr.photos.getAllContexts", array(
"photo_id" => $photo_id,
));
return $this->parsed_response ? $this->parsed_response : false;
}
function photos_getContactsPhotos($count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL) {
$this
->request("flickr.photos.getContactsPhotos", array(
"count" => $count,
"just_friends" => $just_friends,
"single_photo" => $single_photo,
"include_self" => $include_self,
"extras" => $extras,
));
return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
}
function photos_getContactsPublicPhotos($user_id, $count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL) {
$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,
));
return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
}
function photos_getContext($photo_id) {
$this
->request("flickr.photos.getContext", array(
"photo_id" => $photo_id,
));
return $this->parsed_response ? $this->parsed_response : false;
}
function photos_getCounts($dates = NULL, $taken_dates = NULL) {
$this
->request("flickr.photos.getCounts", array(
"dates" => $dates,
"taken_dates" => $taken_dates,
));
return $this->parsed_response ? $this->parsed_response['photocounts']['photocount'] : false;
}
function photos_getExif($photo_id, $secret = NULL) {
$this
->request("flickr.photos.getExif", array(
"photo_id" => $photo_id,
"secret" => $secret,
));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_getFavorites($photo_id, $page = NULL, $per_page = NULL) {
$this
->request("flickr.photos.getFavorites", array(
"photo_id" => $photo_id,
"page" => $page,
"per_page" => $per_page,
));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_getInfo($photo_id, $secret = NULL) {
$this
->request("flickr.photos.getInfo", array(
"photo_id" => $photo_id,
"secret" => $secret,
));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_getNotInSet($min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $media = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.photos.getNotInSet', array(
'min_upload_date' => $min_upload_date,
'max_upload_date' => $max_upload_date,
'min_taken_date' => $min_taken_date,
'max_taken_date' => $max_taken_date,
'privacy_filter' => $privacy_filter,
'media' => $media,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function photos_getPerms($photo_id) {
$this
->request("flickr.photos.getPerms", array(
"photo_id" => $photo_id,
));
return $this->parsed_response ? $this->parsed_response['perms'] : false;
}
function photos_getRecent($extras = NULL, $per_page = NULL, $page = NULL) {
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this
->request("flickr.photos.getRecent", array(
"extras" => $extras,
"per_page" => $per_page,
"page" => $page,
));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_getSizes($photo_id) {
$this
->request("flickr.photos.getSizes", array(
"photo_id" => $photo_id,
));
return $this->parsed_response ? $this->parsed_response['sizes']['size'] : false;
}
function photos_getUntagged($min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $media = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.photos.getUntagged', array(
'min_upload_date' => $min_upload_date,
'max_upload_date' => $max_upload_date,
'min_taken_date' => $min_taken_date,
'max_taken_date' => $max_taken_date,
'privacy_filter' => $privacy_filter,
'media' => $media,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function photos_getWithGeoData($args = array()) {
$this
->request("flickr.photos.getWithGeoData", $args);
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_getWithoutGeoData($args = array()) {
$this
->request("flickr.photos.getWithoutGeoData", $args);
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_recentlyUpdated($min_date, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.photos.recentlyUpdated', array(
'min_date' => $min_date,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function photos_removeTag($tag_id) {
$this
->request("flickr.photos.removeTag", array(
"tag_id" => $tag_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_search($args = array()) {
$this
->request("flickr.photos.search", $args);
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_setContentType($photo_id, $content_type) {
return $this
->call('flickr.photos.setContentType', array(
'photo_id' => $photo_id,
'content_type' => $content_type,
));
}
function photos_setDates($photo_id, $date_posted = NULL, $date_taken = NULL, $date_taken_granularity = NULL) {
$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);
return $this->parsed_response ? true : false;
}
function photos_setMeta($photo_id, $title, $description) {
$this
->request("flickr.photos.setMeta", array(
"photo_id" => $photo_id,
"title" => $title,
"description" => $description,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_setPerms($photo_id, $is_public, $is_friend, $is_family, $perm_comment, $perm_addmeta) {
$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);
return $this->parsed_response ? true : false;
}
function photos_setSafetyLevel($photo_id, $safety_level = NULL, $hidden = NULL) {
return $this
->call('flickr.photos.setSafetyLevel', array(
'photo_id' => $photo_id,
'safety_level' => $safety_level,
'hidden' => $hidden,
));
}
function photos_setTags($photo_id, $tags) {
$this
->request("flickr.photos.setTags", array(
"photo_id" => $photo_id,
"tags" => $tags,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_comments_addComment($photo_id, $comment_text) {
$this
->request("flickr.photos.comments.addComment", array(
"photo_id" => $photo_id,
"comment_text" => $comment_text,
), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
function photos_comments_deleteComment($comment_id) {
$this
->request("flickr.photos.comments.deleteComment", array(
"comment_id" => $comment_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_comments_editComment($comment_id, $comment_text) {
$this
->request("flickr.photos.comments.editComment", array(
"comment_id" => $comment_id,
"comment_text" => $comment_text,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_comments_getList($photo_id, $min_comment_date = NULL, $max_comment_date = NULL) {
return $this
->call('flickr.photos.comments.getList', array(
'photo_id' => $photo_id,
'min_comment_date' => $min_comment_date,
'max_comment_date' => $max_comment_date,
));
}
function photos_comments_getRecentForContacts($date_lastcomment = NULL, $contacts_filter = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.photos.comments.getRecentForContacts', array(
'date_lastcomment' => $date_lastcomment,
'contacts_filter' => $contacts_filter,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function photos_geo_batchCorrectLocation($lat, $lon, $accuracy, $place_id = NULL, $woe_id = NULL) {
return $this
->call('flickr.photos.geo.batchCorrectLocation', array(
'lat' => $lat,
'lon' => $lon,
'accuracy' => $accuracy,
'place_id' => $place_id,
'woe_id' => $woe_id,
));
}
function photos_geo_correctLocation($photo_id, $place_id = NULL, $woe_id = NULL) {
return $this
->call('flickr.photos.geo.correctLocation', array(
'photo_id' => $photo_id,
'place_id' => $place_id,
'woe_id' => $woe_id,
));
}
function photos_geo_getLocation($photo_id) {
$this
->request("flickr.photos.geo.getLocation", array(
"photo_id" => $photo_id,
));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_geo_getPerms($photo_id) {
$this
->request("flickr.photos.geo.getPerms", array(
"photo_id" => $photo_id,
));
return $this->parsed_response ? $this->parsed_response['perms'] : false;
}
function photos_geo_photosForLocation($lat, $lon, $accuracy = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.photos.geo.photosForLocation', array(
'lat' => $lat,
'lon' => $lon,
'accuracy' => $accuracy,
'extras' => $extras,
'per_page' => $per_page,
'page' => $page,
));
}
function photos_geo_removeLocation($photo_id) {
$this
->request("flickr.photos.geo.removeLocation", array(
"photo_id" => $photo_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_geo_setContext($photo_id, $context) {
return $this
->call('flickr.photos.geo.setContext', array(
'photo_id' => $photo_id,
'context' => $context,
));
}
function photos_geo_setLocation($photo_id, $lat, $lon, $accuracy = NULL, $context = NULL) {
return $this
->call('flickr.photos.geo.setLocation', array(
'photo_id' => $photo_id,
'lat' => $lat,
'lon' => $lon,
'accuracy' => $accuracy,
'context' => $context,
));
}
function photos_geo_setPerms($is_public, $is_contact, $is_friend, $is_family, $photo_id) {
return $this
->call('flickr.photos.geo.setPerms', array(
'is_public' => $is_public,
'is_contact' => $is_contact,
'is_friend' => $is_friend,
'is_family' => $is_family,
'photo_id' => $photo_id,
));
}
function photos_licenses_getInfo() {
$this
->request("flickr.photos.licenses.getInfo");
return $this->parsed_response ? $this->parsed_response['licenses']['license'] : false;
}
function photos_licenses_setLicense($photo_id, $license_id) {
$this
->request("flickr.photos.licenses.setLicense", array(
"photo_id" => $photo_id,
"license_id" => $license_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_notes_add($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text) {
$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);
return $this->parsed_response ? $this->parsed_response['note'] : false;
}
function photos_notes_delete($note_id) {
$this
->request("flickr.photos.notes.delete", array(
"note_id" => $note_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_notes_edit($note_id, $note_x, $note_y, $note_w, $note_h, $note_text) {
$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);
return $this->parsed_response ? true : false;
}
function photos_transform_rotate($photo_id, $degrees) {
$this
->request("flickr.photos.transform.rotate", array(
"photo_id" => $photo_id,
"degrees" => $degrees,
), TRUE);
return $this->parsed_response ? true : false;
}
function photos_people_add($photo_id, $user_id, $person_x = NULL, $person_y = NULL, $person_w = NULL, $person_h = NULL) {
return $this
->call('flickr.photos.people.add', array(
'photo_id' => $photo_id,
'user_id' => $user_id,
'person_x' => $person_x,
'person_y' => $person_y,
'person_w' => $person_w,
'person_h' => $person_h,
));
}
function photos_people_delete($photo_id, $user_id) {
return $this
->call('flickr.photos.people.delete', array(
'photo_id' => $photo_id,
'user_id' => $user_id,
));
}
function photos_people_deleteCoords($photo_id, $user_id) {
return $this
->call('flickr.photos.people.deleteCoords', array(
'photo_id' => $photo_id,
'user_id' => $user_id,
));
}
function photos_people_editCoords($photo_id, $user_id, $person_x, $person_y, $person_w, $person_h) {
return $this
->call('flickr.photos.people.editCoords', array(
'photo_id' => $photo_id,
'user_id' => $user_id,
'person_x' => $person_x,
'person_y' => $person_y,
'person_w' => $person_w,
'person_h' => $person_h,
));
}
function photos_people_getList($photo_id) {
return $this
->call('flickr.photos.people.getList', array(
'photo_id' => $photo_id,
));
}
function photos_upload_checkTickets($tickets) {
if (is_array($tickets)) {
$tickets = implode(",", $tickets);
}
$this
->request("flickr.photos.upload.checkTickets", array(
"tickets" => $tickets,
), TRUE);
return $this->parsed_response ? $this->parsed_response['uploader']['ticket'] : false;
}
function photosets_addPhoto($photoset_id, $photo_id) {
$this
->request("flickr.photosets.addPhoto", array(
"photoset_id" => $photoset_id,
"photo_id" => $photo_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_create($title, $description, $primary_photo_id) {
$this
->request("flickr.photosets.create", array(
"title" => $title,
"primary_photo_id" => $primary_photo_id,
"description" => $description,
), TRUE);
return $this->parsed_response ? $this->parsed_response['photoset'] : false;
}
function photosets_delete($photoset_id) {
$this
->request("flickr.photosets.delete", array(
"photoset_id" => $photoset_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_editMeta($photoset_id, $title, $description = NULL) {
$this
->request("flickr.photosets.editMeta", array(
"photoset_id" => $photoset_id,
"title" => $title,
"description" => $description,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_editPhotos($photoset_id, $primary_photo_id, $photo_ids) {
$this
->request("flickr.photosets.editPhotos", array(
"photoset_id" => $photoset_id,
"primary_photo_id" => $primary_photo_id,
"photo_ids" => $photo_ids,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_getContext($photo_id, $photoset_id) {
$this
->request("flickr.photosets.getContext", array(
"photo_id" => $photo_id,
"photoset_id" => $photoset_id,
));
return $this->parsed_response ? $this->parsed_response : false;
}
function photosets_getInfo($photoset_id) {
$this
->request("flickr.photosets.getInfo", array(
"photoset_id" => $photoset_id,
));
return $this->parsed_response ? $this->parsed_response['photoset'] : false;
}
function photosets_getList($user_id = NULL) {
$this
->request("flickr.photosets.getList", array(
"user_id" => $user_id,
));
return $this->parsed_response ? $this->parsed_response['photosets'] : false;
}
function photosets_getPhotos($photoset_id, $extras = NULL, $privacy_filter = NULL, $per_page = NULL, $page = NULL, $media = NULL) {
return $this
->call('flickr.photosets.getPhotos', array(
'photoset_id' => $photoset_id,
'extras' => $extras,
'privacy_filter' => $privacy_filter,
'per_page' => $per_page,
'page' => $page,
'media' => $media,
));
}
function photosets_orderSets($photoset_ids) {
if (is_array($photoset_ids)) {
$photoset_ids = implode(",", $photoset_ids);
}
$this
->request("flickr.photosets.orderSets", array(
"photoset_ids" => $photoset_ids,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_removePhoto($photoset_id, $photo_id) {
$this
->request("flickr.photosets.removePhoto", array(
"photoset_id" => $photoset_id,
"photo_id" => $photo_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_comments_addComment($photoset_id, $comment_text) {
$this
->request("flickr.photosets.comments.addComment", array(
"photoset_id" => $photoset_id,
"comment_text" => $comment_text,
), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
function photosets_comments_deleteComment($comment_id) {
$this
->request("flickr.photosets.comments.deleteComment", array(
"comment_id" => $comment_id,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_comments_editComment($comment_id, $comment_text) {
$this
->request("flickr.photosets.comments.editComment", array(
"comment_id" => $comment_id,
"comment_text" => $comment_text,
), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_comments_getList($photoset_id) {
$this
->request("flickr.photosets.comments.getList", array(
"photoset_id" => $photoset_id,
));
return $this->parsed_response ? $this->parsed_response['comments'] : false;
}
function places_find($query) {
return $this
->call('flickr.places.find', array(
'query' => $query,
));
}
function places_findByLatLon($lat, $lon, $accuracy = NULL) {
return $this
->call('flickr.places.findByLatLon', array(
'lat' => $lat,
'lon' => $lon,
'accuracy' => $accuracy,
));
}
function places_getChildrenWithPhotosPublic($place_id = NULL, $woe_id = NULL) {
return $this
->call('flickr.places.getChildrenWithPhotosPublic', array(
'place_id' => $place_id,
'woe_id' => $woe_id,
));
}
function places_getInfo($place_id = NULL, $woe_id = NULL) {
return $this
->call('flickr.places.getInfo', array(
'place_id' => $place_id,
'woe_id' => $woe_id,
));
}
function places_getInfoByUrl($url) {
return $this
->call('flickr.places.getInfoByUrl', array(
'url' => $url,
));
}
function places_getPlaceTypes() {
return $this
->call('flickr.places.getPlaceTypes', array());
}
function places_getShapeHistory($place_id = NULL, $woe_id = NULL) {
return $this
->call('flickr.places.getShapeHistory', array(
'place_id' => $place_id,
'woe_id' => $woe_id,
));
}
function places_getTopPlacesList($place_type_id, $date = NULL, $woe_id = NULL, $place_id = NULL) {
return $this
->call('flickr.places.getTopPlacesList', array(
'place_type_id' => $place_type_id,
'date' => $date,
'woe_id' => $woe_id,
'place_id' => $place_id,
));
}
function places_placesForBoundingBox($bbox, $place_type = NULL, $place_type_id = NULL) {
return $this
->call('flickr.places.placesForBoundingBox', array(
'bbox' => $bbox,
'place_type' => $place_type,
'place_type_id' => $place_type_id,
));
}
function places_placesForContacts($place_type = NULL, $place_type_id = NULL, $woe_id = NULL, $place_id = NULL, $threshold = NULL, $contacts = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) {
return $this
->call('flickr.places.placesForContacts', array(
'place_type' => $place_type,
'place_type_id' => $place_type_id,
'woe_id' => $woe_id,
'place_id' => $place_id,
'threshold' => $threshold,
'contacts' => $contacts,
'min_upload_date' => $min_upload_date,
'max_upload_date' => $max_upload_date,
'min_taken_date' => $min_taken_date,
'max_taken_date' => $max_taken_date,
));
}
function places_placesForTags($place_type_id, $woe_id = NULL, $place_id = NULL, $threshold = NULL, $tags = NULL, $tag_mode = NULL, $machine_tags = NULL, $machine_tag_mode = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) {
return $this
->call('flickr.places.placesForTags', array(
'place_type_id' => $place_type_id,
'woe_id' => $woe_id,
'place_id' => $place_id,
'threshold' => $threshold,
'tags' => $tags,
'tag_mode' => $tag_mode,
'machine_tags' => $machine_tags,
'machine_tag_mode' => $machine_tag_mode,
'min_upload_date' => $min_upload_date,
'max_upload_date' => $max_upload_date,
'min_taken_date' => $min_taken_date,
'max_taken_date' => $max_taken_date,
));
}
function places_placesForUser($place_type_id = NULL, $place_type = NULL, $woe_id = NULL, $place_id = NULL, $threshold = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) {
return $this
->call('flickr.places.placesForUser', array(
'place_type_id' => $place_type_id,
'place_type' => $place_type,
'woe_id' => $woe_id,
'place_id' => $place_id,
'threshold' => $threshold,
'min_upload_date' => $min_upload_date,
'max_upload_date' => $max_upload_date,
'min_taken_date' => $min_taken_date,
'max_taken_date' => $max_taken_date,
));
}
function places_resolvePlaceId($place_id) {
$rsp = $this
->call('flickr.places.resolvePlaceId', array(
'place_id' => $place_id,
));
return $rsp ? $rsp['location'] : $rsp;
}
function places_resolvePlaceURL($url) {
$rsp = $this
->call('flickr.places.resolvePlaceURL', array(
'url' => $url,
));
return $rsp ? $rsp['location'] : $rsp;
}
function places_tagsForPlace($woe_id = NULL, $place_id = NULL, $min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL) {
return $this
->call('flickr.places.tagsForPlace', array(
'woe_id' => $woe_id,
'place_id' => $place_id,
'min_upload_date' => $min_upload_date,
'max_upload_date' => $max_upload_date,
'min_taken_date' => $min_taken_date,
'max_taken_date' => $max_taken_date,
));
}
function prefs_getContentType() {
$rsp = $this
->call('flickr.prefs.getContentType', array());
return $rsp ? $rsp['person'] : $rsp;
}
function prefs_getGeoPerms() {
return $this
->call('flickr.prefs.getGeoPerms', array());
}
function prefs_getHidden() {
$rsp = $this
->call('flickr.prefs.getHidden', array());
return $rsp ? $rsp['person'] : $rsp;
}
function prefs_getPrivacy() {
$rsp = $this
->call('flickr.prefs.getPrivacy', array());
return $rsp ? $rsp['person'] : $rsp;
}
function prefs_getSafetyLevel() {
$rsp = $this
->call('flickr.prefs.getSafetyLevel', array());
return $rsp ? $rsp['person'] : $rsp;
}
function reflection_getMethodInfo($method_name) {
$this
->request("flickr.reflection.getMethodInfo", array(
"method_name" => $method_name,
));
return $this->parsed_response ? $this->parsed_response : false;
}
function reflection_getMethods() {
$this
->request("flickr.reflection.getMethods");
return $this->parsed_response ? $this->parsed_response['methods']['method'] : false;
}
function stats_getCollectionDomains($date, $collection_id = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getCollectionDomains', array(
'date' => $date,
'collection_id' => $collection_id,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getCollectionReferrers($date, $domain, $collection_id = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getCollectionReferrers', array(
'date' => $date,
'domain' => $domain,
'collection_id' => $collection_id,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getCollectionStats($date, $collection_id) {
return $this
->call('flickr.stats.getCollectionStats', array(
'date' => $date,
'collection_id' => $collection_id,
));
}
function stats_getCSVFiles() {
return $this
->call('flickr.stats.getCSVFiles', array());
}
function stats_getPhotoDomains($date, $photo_id = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getPhotoDomains', array(
'date' => $date,
'photo_id' => $photo_id,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getPhotoReferrers($date, $domain, $photo_id = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getPhotoReferrers', array(
'date' => $date,
'domain' => $domain,
'photo_id' => $photo_id,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getPhotosetDomains($date, $photoset_id = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getPhotosetDomains', array(
'date' => $date,
'photoset_id' => $photoset_id,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getPhotosetReferrers($date, $domain, $photoset_id = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getPhotosetReferrers', array(
'date' => $date,
'domain' => $domain,
'photoset_id' => $photoset_id,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getPhotosetStats($date, $photoset_id) {
return $this
->call('flickr.stats.getPhotosetStats', array(
'date' => $date,
'photoset_id' => $photoset_id,
));
}
function stats_getPhotoStats($date, $photo_id) {
return $this
->call('flickr.stats.getPhotoStats', array(
'date' => $date,
'photo_id' => $photo_id,
));
}
function stats_getPhotostreamDomains($date, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getPhotostreamDomains', array(
'date' => $date,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getPhotostreamReferrers($date, $domain, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getPhotostreamReferrers', array(
'date' => $date,
'domain' => $domain,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getPhotostreamStats($date) {
return $this
->call('flickr.stats.getPhotostreamStats', array(
'date' => $date,
));
}
function stats_getPopularPhotos($date = NULL, $sort = NULL, $per_page = NULL, $page = NULL) {
return $this
->call('flickr.stats.getPopularPhotos', array(
'date' => $date,
'sort' => $sort,
'per_page' => $per_page,
'page' => $page,
));
}
function stats_getTotalViews($date = NULL) {
return $this
->call('flickr.stats.getTotalViews', array(
'date' => $date,
));
}
function tags_getClusterPhotos($tag, $cluster_id) {
return $this
->call('flickr.tags.getClusterPhotos', array(
'tag' => $tag,
'cluster_id' => $cluster_id,
));
}
function tags_getClusters($tag) {
return $this
->call('flickr.tags.getClusters', array(
'tag' => $tag,
));
}
function tags_getHotList($period = NULL, $count = NULL) {
$this
->request("flickr.tags.getHotList", array(
"period" => $period,
"count" => $count,
));
return $this->parsed_response ? $this->parsed_response['hottags'] : false;
}
function tags_getListPhoto($photo_id) {
$this
->request("flickr.tags.getListPhoto", array(
"photo_id" => $photo_id,
));
return $this->parsed_response ? $this->parsed_response['photo']['tags']['tag'] : false;
}
function tags_getListUser($user_id = NULL) {
$this
->request("flickr.tags.getListUser", array(
"user_id" => $user_id,
));
return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false;
}
function tags_getListUserPopular($user_id = NULL, $count = NULL) {
$this
->request("flickr.tags.getListUserPopular", array(
"user_id" => $user_id,
"count" => $count,
));
return $this->parsed_response ? $this->parsed_response['who']['tags']['tag'] : false;
}
function tags_getListUserRaw($tag = NULL) {
return $this
->call('flickr.tags.getListUserRaw', array(
'tag' => $tag,
));
}
function tags_getRelated($tag) {
$this
->request("flickr.tags.getRelated", array(
"tag" => $tag,
));
return $this->parsed_response ? $this->parsed_response['tags'] : false;
}
function test_echo($args = array()) {
$this
->request("flickr.test.echo", $args);
return $this->parsed_response ? $this->parsed_response : false;
}
function test_login() {
$this
->request("flickr.test.login");
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
function urls_getGroup($group_id) {
$this
->request("flickr.urls.getGroup", array(
"group_id" => $group_id,
));
return $this->parsed_response ? $this->parsed_response['group']['url'] : false;
}
function urls_getUserPhotos($user_id = NULL) {
$this
->request("flickr.urls.getUserPhotos", array(
"user_id" => $user_id,
));
return $this->parsed_response ? $this->parsed_response['user']['url'] : false;
}
function urls_getUserProfile($user_id = NULL) {
$this
->request("flickr.urls.getUserProfile", array(
"user_id" => $user_id,
));
return $this->parsed_response ? $this->parsed_response['user']['url'] : false;
}
function urls_lookupGallery($url) {
return $this
->call('flickr.urls.lookupGallery', array(
'url' => $url,
));
}
function urls_lookupGroup($url) {
$this
->request("flickr.urls.lookupGroup", array(
"url" => $url,
));
return $this->parsed_response ? $this->parsed_response['group'] : false;
}
function urls_lookupUser($url) {
$this
->request("flickr.urls.lookupUser", array(
"url" => $url,
));
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
}
}
if (!class_exists('phpFlickr_pager')) {
class phpFlickr_pager {
var $phpFlickr, $per_page, $method, $args, $results, $global_phpFlickr;
var $total = null, $page = 0, $pages = null, $photos, $_extra = null;
function phpFlickr_pager($phpFlickr, $method = null, $args = null, $per_page = 30) {
$this->per_page = $per_page;
$this->method = $method;
$this->args = $args;
$this
->set_phpFlickr($phpFlickr);
}
function set_phpFlickr($phpFlickr) {
if (is_a($phpFlickr, 'phpFlickr')) {
$this->phpFlickr = $phpFlickr;
if ($this->phpFlickr->cache) {
$this->args['per_page'] = 500;
}
else {
$this->args['per_page'] = (int) $this->per_page;
}
}
}
function __sleep() {
return array(
'method',
'args',
'per_page',
'page',
'_extra',
);
}
function load($page) {
$allowed_methods = array(
'flickr.photos.search' => 'photos',
'flickr.photosets.getPhotos' => 'photoset',
);
if (!in_array($this->method, array_keys($allowed_methods))) {
return false;
}
if ($this->phpFlickr->cache) {
$min = ($page - 1) * $this->per_page;
$max = $page * $this->per_page - 1;
if (floor($min / 500) == floor($max / 500)) {
$this->args['page'] = floor($min / 500) + 1;
$this->results = $this->phpFlickr
->call($this->method, $this->args);
if ($this->results) {
$this->results = $this->results[$allowed_methods[$this->method]];
$this->photos = array_slice($this->results['photo'], $min % 500, $this->per_page);
$this->total = $this->results['total'];
$this->pages = ceil($this->results['total'] / $this->per_page);
return true;
}
else {
return false;
}
}
else {
$this->args['page'] = floor($min / 500) + 1;
$this->results = $this->phpFlickr
->call($this->method, $this->args);
if ($this->results) {
$this->results = $this->results[$allowed_methods[$this->method]];
$this->photos = array_slice($this->results['photo'], $min % 500);
$this->total = $this->results['total'];
$this->pages = ceil($this->results['total'] / $this->per_page);
$this->args['page'] = floor($min / 500) + 2;
$this->results = $this->phpFlickr
->call($this->method, $this->args);
if ($this->results) {
$this->results = $this->results[$allowed_methods[$this->method]];
$this->photos = array_merge($this->photos, array_slice($this->results['photo'], 0, $max % 500 + 1));
}
return true;
}
else {
return false;
}
}
}
else {
$this->args['page'] = $page;
$this->results = $this->phpFlickr
->call($this->method, $this->args);
if ($this->results) {
$this->results = $this->results[$allowed_methods[$this->method]];
$this->photos = $this->results['photo'];
$this->total = $this->results['total'];
$this->pages = $this->results['pages'];
return true;
}
else {
return false;
}
}
}
function get($page = null) {
if (is_null($page)) {
$page = $this->page;
}
else {
$this->page = $page;
}
if ($this
->load($page)) {
return $this->photos;
}
$this->total = 0;
$this->pages = 0;
return array();
}
function next() {
$this->page++;
if ($this
->load($this->page)) {
return $this->photos;
}
$this->total = 0;
$this->pages = 0;
return array();
}
}
}