/** * Obtener la ultima foto subida. * * @return Zend_Gdata_Photos_PhotoFeed */ public function getLastPhotoUpload() { $query = $this->_photos->newUserQuery(); $query->setKind("photo"); $query->setMaxResults("1"); $entry = $this->_photos->getUserFeed(null, $query); return $entry[0]; }
function getUserFeed() { plgSystemGdata::gimport('Zend.Gdata.ClientLogin'); plgSystemGdata::gimport('Zend.Gdata.Photos'); plgSystemGdata::gimport('Zend.Gdata.AuthSub'); // Get plugin info $plugin =& JPluginHelper::getPlugin('system', 'gdata'); $params = new JParameter($plugin->params); $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"); $userFeed = $gp->getUserFeed("default"); return $userFeed; }
/** * Outputs an HTML unordered list (ul), with each list item representing an * album in the user's feed. * * @param Zend_Http_Client $client The authenticated client object * @param string $user The user's account name * @return void */ function outputUserFeed($client, $user) { $photos = new Zend_Gdata_Photos($client); $query = new Zend_Gdata_Photos_UserQuery(); $query->setUser($user); $userFeed = $photos->getUserFeed(null, $query); echo "<h2>User Feed for: " . $userFeed->getTitle() . "</h2>"; echo "<ul class='user'>\n"; foreach ($userFeed as $entry) { if ($entry instanceof Zend_Gdata_Photos_AlbumEntry) { echo "\t<li class='user'>"; echo "<a href='?command=retrieveAlbumFeed&user="******"&album=" . $entry->getGphotoId(); echo "'>"; $thumb = $entry->getMediaGroup()->getThumbnail(); echo "<img class='thumb' src='" . $thumb[0]->getUrl() . "' /><br />"; echo $entry->getTitle() . "</a>"; echo "<form action='" . getCurrentScript() . "'' method='post' class='deleteForm'>"; echo "<input type='hidden' name='user' value='" . $user . "' />"; echo "<input type='hidden' name='album' value='" . $entry->getGphotoId(); echo "' />"; echo "<input type='hidden' name='command' value='deleteAlbum' />"; echo "<input type='submit' value='Delete' /></form>"; echo "</li>\n"; } } echo "</ul><br />\n"; echo "<h3>Add an Album</h3>"; ?> <form method="POST" action="<?php echo getCurrentScript(); ?> "> <input type="hidden" name="command" value="addAlbum" /> <input type="hidden" name="user" value="<?php echo $user; ?> " /> <input type="text" name="name" /> <input type="submit" name="Add Album" /> </form> <?php displayBackLink(); }
/** * getAjaxPicasaAlbums * * Will get all albums for the user. * * @return string */ function getAjaxPicasaAlbums() { $token = $_POST['picasa_session_token']; if (isset($_SESSION['picasa_albums'])) { $albums = '<select id="albums" name="albums">'; foreach ($_SESSION['picasa_albums'] as $id => $title) { $albums .= '<option value="' . $id . '">' . $title . '</option>'; } $albums .= '</select>'; } else { $httpClient = Zend_Gdata_AuthSub::getHttpClient($token); $picasaService = new Zend_Gdata_Photos($httpClient, "Google-DevelopersGuide-1.0"); try { $feed = $picasaService->getUserFeed("default"); } catch (Zend_Gdata_App_Exception $e) { echo ' <p class="error-alert"> ' . T_('Could not get Picasa data.') . ' </p>'; logError(__FILE__ . ' [' . __LINE__ . '] - Could not get user picasa data. - ' . $e->getMessage()); return; } $albums = '<select id="albums" name="albums">'; $_SESSION['picasa_albums'] = array(); foreach ($feed as $album) { $id = $album->getGphotoId()->text; $title = $album->title->text; $_SESSION['picasa_albums'][$id] = $title; $albums .= '<option value="' . $id . '">' . $title . '</option>'; } $albums .= '</select>'; } echo ' <p>' . $albums . '</p> <div id="selector"> <a href="#" onclick="picasaSelectAll();" id="select-all">' . T_('Select All') . '</a> <a href="#" onclick="picasaSelectNone();" id="select-none">' . T_('Select None') . '</a> </div> <script language="javascript">loadPicasaPhotoEvents("' . $token . '", "' . T_('Could not get photos.') . '");</script> <ul id="photo_list"> <script language="javascript">loadPicasaPhotos("' . $token . '", "' . T_('Could not get photos.') . '");</script> </ul>'; }
function _Authentication() { session_start(); $client = $this->_getAuthSubHttpClient(); // update the second argument to be CompanyName-ProductName-Version try { $gp = new Zend_Gdata_Photos($client, "Google-DevelopersGuide-1.0"); // $gp->enableRequestDebugLogging('/tmp/gp_requests.log'); $user = $gp->getUserFeed(); $email = $user->getGphotoUser() . '@gmail.com'; } catch (Exception $ex) { //echo $ex->getMessage() . '<br/><br/>'; echo "You need To <a href='https://www.google.com/accounts/NewAccount?hl=en&continue=http%3A%2F%2Fpicasaweb.google.com%2Flh%2Flogin%3Fcontinue%3Dhttp%253A%252F%252Fpicasaweb.google.ru%252Fhome&followup=http%3A%2F%2Fpicasaweb.google.ru%2Flh%2Flogin%3Fcontinue%3Dhttp%253A%252F%252Fpicasaweb.google.com%252Fhome&service=lh2<mpl=gp&passive=true'>Register with Picasa</a> to proceed"; exit; } $userData = $this->User_model->getWhere(array('email' => $email), 1); if (!empty($userData)) { $this->user_id = $userData[0]['id']; } $this->client = $client; $this->gp = $gp; $this->username = (string) $user->getGphotoUser(); $this->email = $email; return $email; }
public function getAlbums() { return $this->gData->getUserFeed('default'); }
function embpicasa_js_dlg_markup() { $options = get_option('embpicasa_options'); $success = true; $msg = ''; $opts = ''; if (!empty($options['embpicasa_options_login']) && !empty($options['embpicasa_options_password'])) { try { set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/library'), get_include_path()))); require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Photos'); Zend_Loader::loadClass('Zend_Gdata_Photos_UserQuery'); Zend_Loader::loadClass('Zend_Gdata_Photos_AlbumQuery'); Zend_Loader::loadClass('Zend_Gdata_Photos_PhotoQuery'); $client = Zend_Gdata_ClientLogin::getHttpClient($options['embpicasa_options_login'], $options['embpicasa_options_password'], Zend_Gdata_Photos::AUTH_SERVICE_NAME); $service = new Zend_Gdata_Photos($client); $albums = array(); $results = $service->getUserFeed(); while ($results != null) { foreach ($results as $entry) { $album_id = $entry->gphotoId->text; $album_name = $entry->title->text; $albums[] = array('id' => $album_id, 'name' => $album_name); } try { $results = $results->getNextFeed(); } catch (Exception $e) { $results = null; } } foreach ($albums as $album) { $opts = $opts . '<option value="' . $album['id'] . '">' . $album['name'] . '</option>'; } } catch (Exception $ex) { $success = false; $msg = $ex->getMessage(); } } ?> <div class="hidden"> <div id="embpicasa_dlg" title="Picasa"> <div class="embpicasa_dlg_content" style="padding:0 1em"> <?php if ($success) { ?> <p> <label>Select album:</label> </p> <p> <select id="embpicasa_dlg_content_album" style="width:100%"><?php echo $opts; ?> </select> </p> <?php } else { ?> <div style="padding:1em;" class="ui-state-error ui-corner-all"> <p><strong>ERROR</strong><br /><?php echo $msg; ?> </p> </div> <?php } ?> </div> </div> </div> <style type="text/css"> .ui-button-text-only .ui-button-text {padding:0;} .ui-widget-overlay {background:#AAAAAA;} </style> <?php }
/** * displayEditPicasa * * @return void */ function displayEditPicasa() { $this->displayHeader(); $token = getUserPicasaSessionToken($this->fcmsUser->id); // Setup url for callbacks $callbackUrl = getDomainAndDir(); $callbackUrl .= 'settings.php?view=picasa'; if (!is_null($token)) { $httpClient = Zend_Gdata_AuthSub::getHttpClient($token); $picasaService = new Zend_Gdata_Photos($httpClient, "Google-DevelopersGuide-1.0"); try { $feed = $picasaService->getUserFeed("default"); } catch (Zend_Gdata_App_Exception $e) { print '<div class="error-alert">' . T_('Could not get Picasa session token.') . '</div>'; return; } $username = $feed->getTitle(); $user = '******' . $username . '">' . $username . '</a>'; $status = sprintf(T_('Currently connected as: %s'), $user); $link = '<a class="disconnect" href="?revoke=picasa">' . T_('Disconnect') . '</a>'; } else { $url = Zend_Gdata_AuthSub::getAuthSubTokenUri($callbackUrl, 'https://picasaweb.google.com/data', false, true); $status = T_('Not Connected'); $link = '<a href="' . $url . '">' . T_('Connect') . '</a>'; } echo ' <div class="social-media-connect"> <img class="icon" src="ui/img/picasa.png" alt="Picasa"/> <h2>Picasa Web</h2> <p>' . T_('Picasa Web allows users to share photos with friends and family.') . '</p> <div class="status">' . $status . '</div> <div class="action">' . $link . '</div> </div>'; $this->displayFooter(); }