/** * Adicionar un nuevo album. * * @param string $name name the new album * @return Zend_Gdata_Photos_AlbumEntry */ public function addAlbum($name) { $entry = new Zend_Gdata_Photos_AlbumEntry(); $entry->setTitle($this->_photos->newTitle($name)); $result = $this->_photos->insertAlbumEntry($entry); return $result; }
/** * 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 createAlbum() { $client = $this->photos; $album = new Zend_Gdata_Photos_AlbumEntry(); $album->setTitle($client->newTitle("testAlbum")); $album->setCategory(array($client->newCategory('http://schemas.google.com/photos/2007#album', 'http://schemas.google.com/g/2005#kind'))); $newAlbum = $client->insertAlbumEntry($album); $this->assertEquals($album->getTitle(), $newAlbum->getTitle()); $this->assertEquals($newAlbum->getTitle(), $client->getAlbumEntry($newAlbum->getLink('self')->href)->getTitle()); $albumFeedUri = $newAlbum->getLink('http://schemas.google.com/g/2005#feed')->href; $albumFeed = $client->getAlbumFeed($albumFeedUri); $this->verifyProperty($albumFeed, "title", "text", "testAlbum"); return $newAlbum; }
/** * Delete an AlbumEntry. * * @param Zend_Gdata_Photos_AlbumEntry $album The album entry to * delete. * @param boolean $catch Whether to catch an exception when * modified and re-delete or throw * @return void. * @throws Zend_Gdata_App_Exception * @throws Zend_Gdata_App_HttpException */ public function deleteAlbumEntry($album, $catch) { if ($catch) { try { $this->delete($album); } catch (Zend_Gdata_App_HttpException $e) { if ($e->getResponse()->getStatus() === 409) { $entry = new Zend_Gdata_Photos_AlbumEntry($e->getResponse()->getBody()); $this->delete($entry->getLink('edit')->href); } else { throw $e; } } } else { $this->delete($album); } }
function uploadpicture() { //uploading photo to server $_data['new_album_name'] = $newAlbumName = $this->input->post('new_album_name'); $_data['album_id'] = $albumId = $this->input->post('album_id'); //var_dump($_SESSION); if (!($albumId || $newAlbumName)) { //echo "test"; $_data['msg'] = $msg = 'You should select album or enter new album name'; $_data['albums'] = $this->_getAlbums(); } elseif (!empty($_FILES['image'])) { $uploaddir = BASEPATH . '../pictures'; $fname = $_FILES['image']['name']; $fsize = $_FILES['image']['size']; $ftmpname = $_FILES['image']['tmp_name']; $ext = ''; if (preg_match("/.+(\\..+)\$/i", $fname, $matches)) { $ext = strtolower($matches[1]); } //file extension $filename = $this->_genFileName($ext, $uploaddir); $uploadfile = $uploaddir . '/' . $filename; //debug: //echo $uploadfile; //$fsize < 3000000 //allow to upload only pics that less then file_upload_size bytes if (in_array($ext, array(".gif", ".png", ".jpg"))) { if (move_uploaded_file($ftmpname, $uploadfile)) { //uploaded $uploaded = TRUE; } else { //Error while uploading file } } else { //Picture shouldn't exceed file_upload_size bytes $_data['msg'] = $msg = 'Uploaded file should be a picture'; } } else { $_data['msg'] = $msg = 'You should select picture to upload'; } if (empty($uploaded)) { if (empty($msg)) { $_data['msg'] = $msg = 'Cannot upload file'; } $_data['albums'] = $this->_getAlbums(); $this->load->view('member_post_picture', $_data); //exit; } else { $photoName = "Test"; $photoCaption = "Uploaded to Picasa Web Albums via PHP."; $photoTags = ""; $fd = $this->gp->newMediaFileSource($uploadfile); $fd->setContentType("image/jpeg"); // Create a PhotoEntry $photoEntry = $this->gp->newPhotoEntry(); $photoEntry->setMediaSource($fd); $photoEntry->setTitle($this->gp->newTitle($photoName)); $photoEntry->setSummary($this->gp->newSummary($photoCaption)); // add some tags $keywords = new Zend_Gdata_Media_Extension_MediaKeywords(); $keywords->setText($photoTags); $photoEntry->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup(); $photoEntry->mediaGroup->keywords = $keywords; // We use the AlbumQuery class to generate the URL for the album $albumQuery = $this->gp->newAlbumQuery(); $albumQuery->setUser($this->username); if ($albumId) { $albumQuery->setAlbumId($albumId); } else { $entry = new Zend_Gdata_Photos_AlbumEntry(); $entry->setTitle($this->gp->newTitle($newAlbumName)); $entry->setSummary($this->gp->newSummary("")); $createdEntry = $this->gp->insertAlbumEntry($entry); //$albumQuery->setAlbumName($newAlbumName); $albumQuery->setAlbumId((string) $createdEntry->gphotoId); //Zend_Debug::dump((string)$createdEntry->gphotoId); } // We insert the photo, and the server returns the entry representing // that photo after it is uploaded $insertedEntry = $this->gp->insertPhotoEntry($photoEntry, $albumQuery->getQueryUrl()); if ($insertedEntry->getMediaGroup()->getContent() != null) { $mediaContentArray = $insertedEntry->getMediaGroup()->getContent(); $contentUrl = $mediaContentArray[0]->getUrl(); print "<pre>"; var_dump($contentUrl); print "</pre>"; if (!empty($this->fbUserId) && !empty($this->userSettings) && $this->userSettings[0]['facebook_pics_y_n'] == 1) { // uploading picture to Facebook //$Albums = $this->facebook->api_client->photos_getAlbums($this->fbUserId, null); //if(!empty($Albums)) $AlbumId = $Albums[0]['aid']; else $AlbumId = null; //print"<pre>";var_dump($AlbumId);print"</pre>"; try { $this->facebook->api_client->photos_upload($uploadfile, null, "Uploading image with " . $this->conf['site_name'], $this->fbUserId); //$this->facebook->api_client->photos_upload($uploadfile, $AlbumId, "Uploading image with pep6", $this->fbUserId); } catch (Exception $ex) { echo $ex->getMessage(); //echo "Cannot upload picture to facebook"; } } $lastMessage = $this->Post_model->getWhere(null, $limit = 1, $offset = 0, $order = 'id DESC'); if (!empty($lastMessage) && $lastMessage[0]['user_id'] == $this->getUserId() && $lastMessage[0]['site_id'] == $this->subdomainId && $lastMessage[0]['post_type'] == 'picture') { $this->Post_pictures_model->insert($lastMessage[0]['id'], $contentUrl); } else { $this->Post_model->insert($this->getUserId(), $this->subdomainId, date("Y-m-d H:i"), 'picture', $contentUrl, NULL, NULL); } $this->load->view('member_post_picture_success', $_data); $sitedata = $this->Site_model->getById($this->subdomainId); $users = $this->User_is_member_of_site_model->getList(0, 0, array('subscribe_y_n' => 1, 'site_id' => $this->subdomainId), '', array('table' => 'users', 'field1' => 'id', 'field2' => 'user_id')); foreach ($users as $user) { $this->_sendemail('newpost', array('sitename' => $sitedata['name'], 'subdomain' => $sitedata['subdomain'], 'email' => $user['email'])); } @unlink($uploadfile); } } }
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; }
function _insertAlbum($data) { $new_access = $this->_service->newAccess(); $new_access->text = 'public'; $entry = new Zend_Gdata_Photos_AlbumEntry(); $entry->setGphotoAccess($new_access); $entry->setGphotoTimestamp($this->_service->newTimestamp((string) strtotime($data['date']) . '000')); $entry->setTitle($this->_service->newTitle($data['title'])); $entry = $this->_service->insertAlbumEntry($entry); return $entry ? $entry->getGphotoId() : false; }
public function createAlbum($album) { static::auth(); if ($this->albumExists($album)) { $this->status['message'] = "Album '{$album}' already exists."; return $r; } $entry = new Zend_Gdata_Photos_AlbumEntry(); $entry->setTitle(static::$service->newTitle($album)); try { static::$service->insertAlbumEntry($entry); static::$status['error'] = false; static::$status['message'] = "Success !"; } catch (Zend_Gdata_App_HttpException $e) { static::$status['message'] = $e->getMessage(); } catch (Zend_Gdata_App_Exception $e) { static::$status['message'] = $e->getMessage(); } return static::$status; }