コード例 #1
0
ファイル: ApiFactory.php プロジェクト: rezzza/flickr
 /**
  * @param string       $file        file
  * @param string       $title       title
  * @param string       $description description
  * @param string|array $tags        tags
  * @param boolean      $isPublic    isPublic
  * @param boolean      $isFriend    isFriend
  * @param boolean      $isFamily    isFamily
  *
  * @return \SimpleXMLElement
  */
 public function upload($file, $title = null, $description = null, $tags = null, $isPublic = null, $isFriend = null, $isFamily = null)
 {
     $path = realpath($file);
     if (false === $path) {
         throw new \LogicException(sprintf('File "%s" does not exists.', $file));
     }
     if (is_array($tags)) {
         foreach ($tags as $k => $v) {
             $tags[$k] = sprintf('"%s"', $v);
         }
         $tags = implode(' ', $tags);
     }
     $parameters = array('photo' => '@' . $path, 'title' => $title, 'description' => $description, 'tags' => $tags, 'is_public' => (int) $isPublic, 'is_friend' => (int) $isFriend, 'is_family' => (int) $isFamily);
     return $this->call(null, $parameters, $this->metadata->getUploadEndpoint());
 }