Exemplo n.º 1
0
 /**
  * 写真をFlickrにアップロード
  * @param $picture
  * @param null $title
  * @param null $description
  * @param null $tags
  * @return Flickr
  * @throws FlickrFailedException
  */
 public function uploadFlickr($picture, $title = null, $description = null, $tags = null)
 {
     $metadata = new Metadata(config('const.flickr.apikey'), config('const.flickr.secret'));
     $metadata->setOauthAccess(config('const.flickr.oauth_token'), config('const.flickr.oauth_token_secret'));
     $factory = new ApiFactory($metadata, new GuzzleAdapter());
     $upload = $factory->upload($picture, $title, $description, $tags, true);
     if ((string) $upload->attributes()->stat === 'fail') {
         $errAttr = $upload->err->attributes();
         throw new FlickrFailedException((string) $errAttr->msg, (int) $errAttr->code);
     }
     $getInfo = $factory->call('flickr.photos.getInfo', array('photo_id' => (string) $upload->photoid));
     $photoAttr = $getInfo->photo->attributes();
     $flickr = new Flickr();
     foreach (['id', 'server', 'farm', 'secret'] as $name) {
         $flickr->{'flickr_' . $name} = (string) $photoAttr->{$name};
     }
     $flickr->save();
     return $flickr;
 }
Exemplo n.º 2
0
 /**
  * @param $query
  * @param $id
  * @return mixed|null
  */
 public function search($query, $id)
 {
     $flickr = new Flickr();
     return $flickr->search($query, $id);
 }