Example #1
0
 /**
  * @param $group_id
  * @param $photo_id
  * @return string
  * @throws Phlickr_ConnectionException
  */
 public function addToGroup($group_id, $photo_id)
 {
     $url = $this->buildPhotoAddUrl($group_id);
     $params = array_merge($this->_api->getParamsForRequest(), ['photo_id' => $photo_id, 'group_id' => $group_id, 'method' => 'flickr.groups.pools.add']);
     $signing = '';
     ksort($params);
     foreach ($params as $key => $value) {
         $signing .= $key . $value;
     }
     $params['api_sig'] = md5($this->_api->getSecret() . $signing);
     // use the requst to submit
     $result = Phlickr_Request::SubmitHttpPost($url, $params, self::TIMEOUT);
     return $result;
 }
Example #2
0
 /**
  * Upload a photo to Flickr.
  *
  * If tags are specified, they'll be appended to those listed in getTags().
  * If permissions are specified, they'll override those set by setPerms().
  *
  * The permissions assigned will based on those set using setPerms().
  *
  * @param   string $fullFilePath Full path and file name of the photo.
  * @param   string $title Photo title.
  * @param   string $desc Photo description.
  * @param   string|array $tags A space separated list of tags to add to the photo.
  *          These will be added to those listed in getTags().
  * @return  string id of the new photo
  * @throws  Phlickr_ConnectionException
  * @see     isForPublic(), isForFriends(), isForFamily(), getTags()
  */
 public function upload($fullFilePath, $title = '', $desc = '', $tags = '')
 {
     if (!file_exists($fullFilePath) || !is_readable($fullFilePath)) {
         throw new Phlickr_Exception("The file '{$fullFilePath}' does not exist or can not be accessed.");
     }
     // concat the class's tags with this photos.
     if (is_array($tags)) {
         $tags = '"' . implode('" "', $this->_tags + $tags) . '"';
     } elseif ($tags) {
         $tags = '"' . implode('" "', $this->_tags) . '" ' . (string) $tags;
     } else {
         $tags = '';
     }
     // get the parameters ready for signing ...
     $params = array_merge($this->_api->getParamsForRequest(), array('title' => $title, 'description' => $desc, 'tags' => $tags, 'is_public' => (int) $this->_forPublic, 'is_friend' => (int) $this->_forFriends, 'is_family' => (int) $this->_forFamily));
     // ... compute a signature ...
     ksort($params);
     $signing = '';
     foreach ($params as $key => $value) {
         $signing .= $key . $value;
     }
     $params['api_sig'] = md5($this->_api->getSecret() . $signing);
     // ... then put in the photo. the @ tells CURL to upload the file's
     // contents
     $params['photo'] = '@' . $fullFilePath;
     // use the requst to submit
     $result = Phlickr_Request::SubmitHttpPost(self::UPLOAD_URL, $params, self::TIMEOUT);
     // use the reponse object to parse the results
     $resp = new Phlickr_Response($result, true);
     // return a photo id
     return (string) $resp->getXml()->photoid;
 }