diff --git a/lib/flickrlib.php b/lib/flickrlib.php index 14473e35697..983c1b48fad 100755 --- a/lib/flickrlib.php +++ b/lib/flickrlib.php @@ -1079,5 +1079,55 @@ class phpFlickr { $this->request("flickr.urls.lookupUser", array("url"=>$url)); return $this->parsed_response ? $this->parsed_response['user'] : false; } + /** + * upload a photo to flickr + * @param string $photo must be the path of the file + * @param string $title + * @param string $description + * @param string $tags + * @param string $is_public + * @param string $is_friend + * @param string $is_family + * @return boolean + */ + + function upload ($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) { + global $SESSION; + $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->email)) { + $args = array_merge($args, array("email" => $this->email)); + } + if (!empty($this->password)) { + $args = array_merge($args, array("password" => $this->password)); + } + // TODO: + // should we request a token if it is not valid? + if (!empty($this->token)) { + $args = array_merge($args, array("auth_token" => $this->token)); + } + + ksort($args); + $auth_sig = ""; + foreach ($args as $key => $data) { + if ($data !== null) { + $auth_sig .= $key . $data; + } else { + unset($args[$key]); + } + } + if (!empty($this->secret)) { + $api_sig = md5($this->secret . $auth_sig); + $args['api_sig'] = $api_sig; + } + + $photo = realpath($photo); + $args['photo'] = '@'.$photo; + + if ($response = $this->curl->post($this->Upload, $args)) { + return true; + } else { + return false; + } + } } ?> diff --git a/portfolio/type/flickr/lib.php b/portfolio/type/flickr/lib.php index dd64cae0f70..2cdfb3dd96a 100755 --- a/portfolio/type/flickr/lib.php +++ b/portfolio/type/flickr/lib.php @@ -26,7 +26,7 @@ class portfolio_plugin_flickr extends portfolio_plugin_push_base { $filesize = $file->get_filesize(); if ($file->is_valid_image()) { - $return = $this->flickr->request ('upload', array('photo' => $file, + $return = $this->flickr->upload ('upload', array('photo' => $file, 'title' => $this->get_export_config('title'), 'description' => $this->get_export_config('description'), 'tags' => $this->get_export_config('tags'),