/** * Adicionar una nueva foto a un album especifico. * * @param integer $albumId id del album * @param array $photo The uploaded photo * @return Zend_Gdata_Photos_PhotoEntry */ public function insertPhoto($albumId, $photo) { $fd = $this->_photos->newMediaFileSource($photo["tmp_name"]); $fd->setContentType($photo["type"]); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle($this->_photos->newTitle($photo["name"])); $entry->setSummary($this->_photos->newSummary($photo["summary"])); $albumQuery = new Zend_Gdata_Photos_AlbumQuery(); $albumQuery->setAlbumId($albumId); $albumEntry = $this->_photos->getAlbumEntry($albumQuery); try { $photo = $this->_photos->insertPhotoEntry($entry, $albumEntry); } catch (Zend_Exception $e) { //echo $e->getMessage(); } return $photo; }
/** * Adds a new album to the specified user's album * * @param Zend_Http_Client $client The authenticated client * @param string $name The name of the new album * @return void */ function addAlbum($client, $name) { $photos = new Zend_Gdata_Photos($client); $entry = new Zend_Gdata_Photos_AlbumEntry(); $entry->setTitle($photos->newTitle($name)); $result = $photos->insertAlbumEntry($entry); if ($result) { return $result; } else { echo "There was an issue with the album creation."; } }
public function postPhotoToAlbum($photoName, $photoPath, $albumName) { $types = array('jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/jpeg', 'png' => 'image/png'); $source = $this->gData->newMediaFileSource($photoPath); $extension = strtolower(pathinfo($photoPath, PATHINFO_EXTENSION)); $source->setContentType($types[$extension]); $photoEntry = $this->gData->newPhotoEntry(); $photoEntry->setMediaSource($source); $photoEntry->setTitle($this->gData->newTitle($photoName)); $albumQuery = $this->gData->newAlbumQuery(); $albumQuery->setUser($this->user); $albumQuery->setAlbumName($albumName); return $this->gData->insertPhotoEntry($photoEntry, $albumQuery->getQueryUrl()); }
public function picasaUpload($file) { $extension = pathinfo($file->getFileName(), PATHINFO_EXTENSION); $file_path = $this->tempfolder . $this->random_file_name() . "." . $extension; //save file to temp folder //move_uploaded_file($file->getFileName(), $file_path); copy($file->getTempFile(), $file_path); //upload to picasa $token = $this->get_login_token(); //create client $client = new Zend_Gdata_HttpClient(); $client->setAuthSubToken($token); $client->setClientLoginToken($token); //create new photo $gphoto = new Zend_Gdata_Photos($client); $photo = $gphoto->newPhotoEntry(); $gfile = $gphoto->newMediaFileSource($file_path); $gfile->setContentType('image/' . $extension); $photo->setMediaSource($gfile); $photo->setTitle($gphoto->newTitle($file->getFileName())); // link to album $album = $gphoto->newAlbumQuery(); $album->setUser($this->config['user']); $album->setAlbumId($this->config['album_id']); // save photo to album $insertedEntry = $gphoto->insertPhotoEntry($photo, $album->getQueryUrl()); //delete file in temp folder if (file_exists($file_path)) { unlink($file_path); } if ($insertedEntry->getMediaGroup()->getContent() != null) { $photoUrl = $insertedEntry->getMediaGroup()->getContent()[0]->getUrl(); $photoThumbnail = $insertedEntry->getMediaGroup()->getThumbnail()[1]->getUrl(); $photoId = $insertedEntry->getGphotoId(); return array("thumbnail" => $photoThumbnail, "url" => $photoUrl, "id" => $photoId); } else { throw new XenForo_Exception("Cannot get file url"); } }
/** * Adds a new tag to the specified photo * * @param Zend_Http_Client $client The authenticated client * @param string $user The user's account name * @param integer $album The album's id * @param integer $photo The photo's id * @param string $tag The tag to add to the photo * @return void */ function addTag($client, $user, $album, $photo, $tag) { $photos = new Zend_Gdata_Photos($client); $entry = new Zend_Gdata_Photos_TagEntry(); $entry->setTitle($photos->newTitle($tag)); $photoQuery = new Zend_Gdata_Photos_PhotoQuery(); $photoQuery->setUser($user); $photoQuery->setAlbumId($album); $photoQuery->setPhotoId($photo); $photoQuery->setType('entry'); $photoEntry = $photos->getPhotoEntry($photoQuery); $result = $photos->insertTagEntry($entry, $photoEntry); if ($result) { outputPhotoFeed($client, $user, $album, $photo); } else { echo "There was an issue with the tag creation."; } }
public function insertAlbumEntry($title) { // Get plugin info $plugin =& JPluginHelper::getPlugin('system', 'gdata'); $params = new JParameter($plugin->params); plgSystemGdata::gimport('Zend.Gdata.ClientLogin'); plgSystemGdata::gimport('Zend.Gdata.Photos'); plgSystemGdata::gimport('Zend.Gdata.AuthSub'); $username = $params->get('domain_admin_email'); $pass = $params->get('domain_admin_password'); $serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($username, $pass, $serviceName); // update the second argument to be CompanyName-ProductName-Version $gp = new Zend_Gdata_Photos($client, "Google-DevelopersGuide-1.0"); $entry = new Zend_Gdata_Photos_AlbumEntry(); $entry->setTitle($gp->newTitle($title)); $entry->setGphotoAccess($gp->newAccess("public")); $createdEntry = $gp->insertAlbumEntry($entry); return true; }