public function createPhoto($album) { $client = $this->photos; $fd = $client->newMediaFileSource('Zend/Gdata/_files/testImage.jpg'); $fd->setContentType('image/jpeg'); $photo = new Zend_Gdata_Photos_PhotoEntry(); $photo->setMediaSource($fd); $photo->setTitle($client->newTitle("test photo")); $photo->setCategory(array($client->newCategory('http://schemas.google.com/photos/2007#photo', 'http://schemas.google.com/g/2005#kind'))); $newPhoto = $client->insertPhotoEntry($photo, $album); $this->assertEquals($photo->getTitle(), $newPhoto->getTitle()); $this->assertEquals($newPhoto->getTitle(), $client->getPhotoEntry($newPhoto->getLink('self')->href)->getTitle()); $photoFeedUri = $newPhoto->getLink('http://schemas.google.com/g/2005#feed')->href; $photoFeed = $client->getPhotoFeed($photoFeedUri); $this->verifyProperty($photoFeed, "title", "text", "test photo"); return $newPhoto; }
/** * 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 photo to the specified album * * @param Zend_Http_Client $client The authenticated client * @param string $user The user's account name * @param integer $albumId The album's id * @param array $photo The uploaded photo * @return void */ function addPhoto($client, $user, $albumId, $photo) { $photos = new Zend_Gdata_Photos($client); $fd = $photos->newMediaFileSource($photo["tmp_name"]); $fd->setContentType($photo["type"]); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle($photos->newTitle($photo["name"])); $albumQuery = new Zend_Gdata_Photos_AlbumQuery(); $albumQuery->setUser($user); $albumQuery->setAlbumId($albumId); $albumEntry = $photos->getAlbumEntry($albumQuery); $result = $photos->insertPhotoEntry($entry, $albumEntry); if ($result) { outputAlbumFeed($client, $user, $albumId); } else { echo "There was an issue with the file upload."; } }
/** * Adds a new photo to the specified album * * @param Zend_Http_Client $client The authenticated client * @param string $user The user's account name * @param integer $albumId The album's id * @param array $photo The uploaded photo * @return void */ function addPhoto($client, $user, $albumId, $photo_name, $photo_path) { $photos = new Zend_Gdata_Photos($client); $fd = $photos->newMediaFileSource($photo_path); $fd->setContentType('image/jpeg'); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle($photos->newTitle($photo_name)); $albumQuery = new Zend_Gdata_Photos_AlbumQuery(); $albumQuery->setUser($user); $albumQuery->setAlbumId($albumId); $albumEntry = $photos->getAlbumEntry($albumQuery); $result = $photos->insertPhotoEntry($entry, $albumEntry); if ($result) { return $result; } else { echo "There was an issue with the file upload."; } }
function _insertPhoto($data) { $s = @getimagesize($data['image_url']); $fd = $this->_service->newMediaFileSource($data['image_url']); $fd->setContentType(@$s['mime']); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setGphotoTimestamp($this->_service->newTimestamp((string) strtotime($data['date']) . '000')); //$entry->setTitle($this->_service->newTitle($data['description'])); $query = new Zend_Gdata_Photos_AlbumQuery(); $query->setAlbumId($data['parentid']); $album = $this->_service->getAlbumEntry($query); $entry = $this->_service->insertPhotoEntry($entry, $album); return $entry ? $entry->getGphotoId() : false; }
public static function upload($pic, $nameImage) { $cUrl = ""; static::auth(); $fd = static::$service->newMediaFileSource($pic["full_path"]); $fd->setContentType($pic["file_type"]); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle(static::$service->newTitle($nameImage)); $albumQuery = new Zend_Gdata_Photos_AlbumQuery(); $albumQuery->setUser("default"); $albumQuery->setAlbumId(static::$albumID); $albumEntry = static::$service->getAlbumEntry($albumQuery); try { $insertedEntry = static::$service->insertPhotoEntry($entry, $albumEntry); if ($insertedEntry->getMediaGroup()->getContent() != null) { $mediaContentArray = $insertedEntry->getMediaGroup()->getContent(); $wantReplace = "/" . $nameImage; $cUrl = @str_replace($wantReplace, "", $mediaContentArray[0]->getUrl()); $cUrl = static::changelink($cUrl); } static::$status['error'] = false; static::$status['message'] = "Success !"; } catch (Zend_Gdata_App_Exception $e) { //static::$status['message'] =$e->getMessage(); $cUrl = NULL; } return $cUrl; }