function getAuthSubHttpClient() { if (isset($_SESSION['google_session_token'])) { $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['google_session_token']); return $client; } }
public function includes() { set_include_path(PLUGIN_DIR . "wildfire.media.youtube/ZendGdata/library/"); require_once PLUGIN_DIR . 'wildfire.media.youtube/ZendGdata/library/Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_YouTube'); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_App_Exception'); $httpClient = Zend_Gdata_AuthSub::getHttpClient(Config::get('youtube/token')); return new Zend_Gdata_YouTube($httpClient, 0, 0, Config::get('youtube/developer_key')); }
function comment($entry, $comment) { $username = $_SESSION['username']; $query = "select token from user where username='******'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $token = $row['token']; $httpClient = Zend_Gdata_AuthSub::getHttpClient($token); $developerKey = 'AI39si5uCFW5FETweIaPnbNJUP88YvpOtSoy7FSUnYnTFVH4liFKzqWTkndATtgiltByN54tPcVjsScyh3S28P-D4PC4n73alg'; $applicationId = 'EazySubs'; $clientId = 'EazySubs'; $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey); try { $videoEntry = $yt->getVideoEntry($entry); $newComment = $yt->newCommentEntry(); $newComment->content = $yt->newContent()->setText($comment); // post the comment to the comments feed URL for the video $commentFeedPostUrl = $videoEntry->getVideoCommentFeedUrl(); $updatedVideoEntry = $yt->insertEntry($newComment, $commentFeedPostUrl, 'Zend_Gdata_YouTube_CommentEntry'); return true; } catch (Exception $e) { return false; } }
/** * 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>'; }
// lihat di https://developers.google.com/gdata/docs/developers-guide atau // http://stackoverflow.com/questions/10704299/zend-gdata-calendar-api-returns-version-3-0-is-not-supported $httpClient->setHeaders('GData-Version', '2.0'); $youtube = new Zend_Gdata_YouTube($httpClient, APPLICATION_ID, CLIENT_ID, DEVELOPER_KEY); // Variabel $profile akan menyimpan semua informasi profile dari user yang terhubung // dalam bentuk object class Zend_Gdata_YouTube_UserProfileEntry $profile = $youtube->getUserProfile(); </pre> Hasil yang didapat : <pre> <?php $httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); $httpClient->setHeaders('GData-Version', '2.0'); $youtube = new Zend_Gdata_YouTube($httpClient, APP_ID, CLIENT_ID, DEV_KEY); // Variabel $profile akan menyimpan semua informasi profile dari user yang terhubung $profile = $youtube->getUserProfile('default'); echo '// $profile->getUsername();<br/>'; echo $profile->getUsername(); echo '<br/><br/>'; echo '// $profile->getFirstName();<br/>'; echo $profile->getFirstName(); echo '<br/><br/>'; echo '// $profile->getLastName();<br/>'; echo $profile->getLastName(); ?> </pre> </p>
/** * Returns a HTTP client object with the appropriate headers for communicating * with Google using AuthSub authentication. * * Uses the $_SESSION['sessionToken'] to store the AuthSub session token after * it is obtained. The single use token supplied in the URL when redirected * after the user succesfully authenticated to Google is retrieved from the * $_GET['token'] variable. * * @return Zend_Http_Client */ function getAuthSubHttpClient() { global $_SESSION, $_GET; if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); } $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); return $client; }
/** * Convenience method to obtain an authenticted Zend_Http_Client object. * * @return Zend_Http_Client An authenticated client. */ function getAuthSubHttpClient() { try { $httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); } catch (Zend_Gdata_App_Exception $e) { print 'ERROR - Could not obtain authenticated Http client object. ' . $e->getMessage(); return; } $httpClient->setHeaders('X-GData-Key', 'key=' . $_SESSION['developerKey']); return $httpClient; }
} else { if (preg_match('/^<\\/.+>$/', $el)) { $indent -= $level; // closing tag, decrease indent } if ($indent < 0) { $indent += $level; } $pretty[] = str_repeat(' ', $indent) . $el; } } $xml = implode("\n", $pretty); return $html_output ? htmlentities($xml) : $xml; } $sessionToken = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); $client = Zend_Gdata_AuthSub::getHttpClient($sessionToken); $useH9Sandbox = true; $healthService = new Zend_Gdata_Health($client, 'MyGHAppNamev1.0', $useH9Sandbox); $query = new Zend_Gdata_Health_Query(); $query->setDigest("true"); $profileFeed = $healthService->getHealthProfileFeed($query); $entry = $profileFeed->entry[0]; //To print ccr $ccr = $entry->getCcr(); $xmlStr = $ccr->saveXML($ccr); echo '<p>' . xmlpp($xmlStr, true) . '</p>'; // digest=true was set so we only have 1 entry $allergies = $entry->getCcr()->getAllergies(); $conditions = $entry->getCcr()->getConditions(); $immunizations = $entry->getCcr()->getImmunizations(); $lab_results = $entry->getCcr()->getLabResults();
public function googleAction() { //$this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $my_calendar = 'http://www.google.com/calendar/feeds/default/private/full'; if (!isset($_SESSION['cal_token'])) { if (isset($_GET['token'])) { // You can convert the single-use token to a session token. $session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); // Store the session token in our session. $_SESSION['cal_token'] = $session_token; } else { // Display link to generate single-use token $googleUri = Zend_Gdata_AuthSub::getAuthSubTokenUri('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], $my_calendar, 0, 1); echo "Click <a href='{$googleUri}'>here</a> " . "to authorize this application."; exit; } } // Create an authenticated HTTP Client to talk to Google. $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['cal_token']); // Create a Gdata object using the authenticated Http Client $cal = new Zend_Gdata_Calendar($client); var_export($cal->getCalendarListFeed()->count()); }
/** * Return authenticated http client * * @param string $token * * @return \self * * @version 5.0 */ public static function getAuthSubHttpClient($token = false) { $next = elgg_get_site_url() . GLOBAL_IZAP_VIDEOS_PAGEHANDLER . '/upload/' . elgg_get_logged_in_user_entity()->username . '/youtube'; $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; if (!isset($_SESSION['YT_TOKEN']) && !$token) { return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); } else { if (!isset($_SESSION['YT_TOKEN']) && $token) { $_SESSION['YT_TOKEN'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($token); } } return new self(Zend_Gdata_AuthSub::getHttpClient($_SESSION['YT_TOKEN']), izap_admin_settings_izap_videos('youtubeDeveloperKey')); }
function _getAuthSubHttpClient() { //if (!isset($_SESSION['sessionToken']) && !isset($_GET['token']) ){ if (!isset($_COOKIE['sessionToken']) && !isset($_GET['token'])) { //echo '<a href="' . $this->_getAuthSubUrl() . '">Login!</a>'; //exit; redirect('http://' . $_SERVER['HTTP_HOST'] . '/signin'); //} else if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { } else { if (!isset($_COOKIE['sessionToken']) && isset($_GET['token'])) { $sessionToken = $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); $this->load->helper('cookie'); $cookie = array('name' => 'sessionToken', 'value' => $sessionToken, 'expire' => '86500'); set_cookie($cookie); } } //var_dump($_COOKIE); if (!empty($_COOKIE['sessionToken'])) { $client = Zend_Gdata_AuthSub::getHttpClient($_COOKIE['sessionToken']); } else { $client = Zend_Gdata_AuthSub::getHttpClient($sessionToken); } //$client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); $client->setHeaders('X-GData-Key', "key=" . $this->developerKey); $client->setAuthSubPrivateKeyFIle('/var/www/myrsakey.pem', null, true); return $client; /* if (!isset($_SESSION['sessionToken']) && !isset($_GET['token']) ){ echo '<a href="' . $this->_getAuthSubUrl() . '">Login!</a>'; exit; } else if (isset($_GET['token'])) { try{ $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); } catch(Exception $ex) { } } try{ $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); return $client; } catch(Exception $ex) { } return FALSE; */ }
/** * Initialize and return Youtube api object * * @param string authentication method (clientlogin, authsub, oauth2) * @return youtube httpclient object */ public function get_youtube_httpclient($authmethod) { switch ($authmethod) { case "authsub": $httpclient = null; break; case "oauth2": //We have hijacked the AuthSub class, to use OAUTH2. I know, I know ... //But its the best way till API V3 is stable Zend_Loader::loadClass('Zend_Gdata_AuthSub'); $httpclient = Zend_Gdata_AuthSub::getHttpClient($this->youtubeoauth->fetch_accesstoken()); break; case "clientlogin": default: $username = get_config('assignsubmission_youtube', 'youtube_masteruser'); $userpass = get_config('assignsubmission_youtube', 'youtube_masterpass'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); $authenticationURL = 'https://www.google.com/accounts/ClientLogin'; $httpclient = Zend_Gdata_ClientLogin::getHttpClient($username = $username, $password = $userpass, $service = 'youtube', $client = null, $source = 'Moodle Youtube Assignment Submission', $loginToken = null, $loginCaptcha = null, $authenticationURL); } return $httpclient; }
/** * Add a username to the DB using their single-use AuthSub token. * * @param string $token The single-use AuthSub token of the user to be added. * @return void */ function addUsername($token) { $httpClient = Zend_Gdata_AuthSub::getHttpClient($token); $yt = new Zend_Gdata_YouTube($httpClient, 'YT-UeberActivityViewer', $GLOBALS['ueber-activity-viewer-php_config']['client_id'], $GLOBALS['ueber-activity-viewer-php_config']['dev_key']); $yt->setMajorProtocolVersion(2); try { $userProfile = $yt->getUserProfile('default'); } catch (Zend_Gdata_Exception $e) { error_log("Error getting userProfile: " . $e->getMessage()); return null; } unset($yt); if (!$userProfile) { error_log("UserProfile is null."); return null; } $username = $userProfile->getUsername(); $userhash = null; // get hash if ($username) { $yt = getYouTubeService(); try { $activitiesFeed = $yt->getFeed('http://gdata.youtube.com/feeds/api/users/' . $username . '/events'); } catch (Exception $e) { echo "Error retrieving user events feed for {$username} | " . $e->getMessage(); print_r($yt); } $updatesLink = $activitiesFeed->getLink('updates'); $hashHref = $updatesLink->getHref(); $userhash = substr($hashHref, strpos($hashHref, '#') + 1); unset($yt); } else { echo "Could not get user profile for token {$token}."; error_log("Could not get user profile for token {$token}."); header('Location: ' . "http://{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']}"); } $mysqli = new mysqli($GLOBALS['ueber-activity-viewer-php_config']['mysql_hostname'], $GLOBALS['ueber-activity-viewer-php_config']['mysql_username'], $GLOBALS['ueber-activity-viewer-php_config']['mysql_password'], $GLOBALS['ueber-activity-viewer-php_config']['mysql_database'], $GLOBALS['ueber-activity-viewer-php_config']['mysql_port'], $GLOBALS['ueber-activity-viewer-php_config']['mysql_socket']); if (mysqli_connect_errno()) { error_log("Connect failed: " . mysqli_connect_error()); return null; } $username = $mysqli->real_escape_string($username); $userhash = $mysqli->real_escape_string($userhash); $statement = $mysqli->prepare("INSERT IGNORE INTO user (username, hash) VALUES (?,?)"); $statement->bind_param('ss', $username, $userhash); $statement->execute(); $statement->close(); $mysqli->close(); header('Location: ' . "http://{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']}"); }
function gCalDemo() { if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); } $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); // load the library $this->load->library('Gcal'); // examples of useage for each function //################################################ //##############OutputCalendarList################ //################################################ /* $calFeed = $this->gcal->outputCalendarList($client); echo '<h1>' . $calFeed->title->text . '</h1>'; echo '<ul>'; foreach ($calFeed as $calendar) { echo '<li>'.$calendar->title->text.'</li>'; } echo '</ul>'; */ //################################################ //##############End OutputCalendarList############ //################################################ echo "<br />- - - - - - - - - - - - - - - - - - - - \n\t\t\t- - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />"; //################################################ //##############OutputCalendarEvents############## //################################################ /* $eventFeed = $this->gcal->outputCalendarEvents($client); echo "<ul>"; foreach ($eventFeed as $event){ echo "\t<li><b>Event Title: </b>".$event->title->text."</li>\n"; echo "\t\t<ul>\n"; echo "\t\t\t<li><b>Event ID: </b>". $event->id->text ."</li>\n"; echo "\t\t\t<li><b>Content: </b>".$event->content->text."</li>\n"; foreach($event->when as $when){ //echo "<pre>"; //print_r($when); //echo "</pre>"; echo "\t\t\t<li><b>Starts:</b> " . $when->startTime . "</li>\n"; echo "\t\t\t<li><b>Ends:</b> " . $when->endTime . "</li>\n"; } echo "\t\t</ul>\n"; echo "\t</li>\n"; } echo "</ul>"; */ //################################################ //############End OutputCalendarEvents############ //################################################ echo "<br />- - - - - - - - - - - - - - - - - - - - \n\t\t\t- - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />"; //################################################ //##############calEventsByDateRange############## //################################################ /* $startDate = '2009-06-15'; $endDate = '2009-06-17'; $eventQuery = $this->gcal->calEventsByDateRange($client, $startDate, $endDate); echo "<ul>"; foreach ($eventQuery as $event){ echo "\t<li><b>Event Title: </b>".$event->title->text."</li>\n"; echo "\t\t<ul>\n"; echo "\t\t\t<li><b>Event ID: </b>". $event->id->text ."</li>\n"; echo "\t\t\t<li><b>Content: </b>".$event->content->text."</li>\n"; foreach($event->when as $when){ //echo "<pre>"; //print_r($when); //echo "</pre>"; echo "\t\t\t<li><b>Starts:</b> " . $when->startTime . "</li>\n"; echo "\t\t\t<li><b>Ends:</b> " . $when->endTime . "</li>\n"; } echo "\t\t</ul>\n"; echo "\t</li>\n"; } echo "</ul>"; */ //################################################ //############End calEventsByDateRange############ //################################################ echo "<br />- - - - - - - - - - - - - - - - - - - - \n\t\t\t- - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />"; //################################################ //##############calFullTextQuery################## //################################################ /* $query = "enter your query string here"; // searches in both title and event content $eventFullQuery = $this->gcal->calFullTextQuery($client, $query); echo "<ul>"; foreach ($eventFullQuery as $event){ echo "\t<li><b>Event Title: </b>".$event->title->text."</li>\n"; echo "\t\t<ul>\n"; echo "\t\t\t<li><b>Event ID: </b>". $event->id->text ."</li>\n"; echo "\t\t\t<li><b>Content: </b>".$event->content->text."</li>\n"; foreach($event->when as $when){ //echo "<pre>"; //print_r($when); //echo "</pre>"; echo "\t\t\t<li><b>Starts:</b> " . $when->startTime . "</li>\n"; echo "\t\t\t<li><b>Ends:</b> " . $when->endTime . "</li>\n"; } echo "\t\t</ul>\n"; echo "\t</li>\n"; } echo "</ul>"; */ //################################################ //##############End calFullTextQuery############## //################################################ echo "<br />- - - - - - - - - - - - - - - - - - - - \n\t\t\t- - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />"; //################################################ //#################createEvent#################### //################################################ /* $eventArray = array('title' => 'My test event', 'desc' => 'This is a description for my test event', 'where' => 'My house', 'startDate' => '2009-06-16', 'startTime' => '22:00', 'endDate' => '2009-06-17', 'endTime' => '04:00', 'tzOffset' => '-04' ); $this->gcal->createEvent($client, $eventArray); */ //################################################ //###############End createEvent################## //################################################ echo "<br />- - - - - - - - - - - - - - - - - - - - \n\t\t\t- - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />"; //################################################ //##############createQuickEvent################## //################################################ /* // include a time + am/pm and day // day can be day of the week or tomorrow // can use a format like "next tuesday" $eventInfo = "Dinner at my house next tuesday at 9pm"; $this->gcal->createQuickEvent($client, $eventInfo); */ //################################################ //##############End createQuickEvent############## //################################################ }
/** * getYouTubeAuthSubHttpClient * * @param string $key the developer key * @param string $token optional user's authenticated session token * * @return Zend_Http_Client An authenticated client. */ function getYouTubeAuthSubHttpClient($key, $token = '') { if ($token == '') { if (isset($_SESSION['youtube_session_token'])) { $token = $_SESSION['youtube_session_token']; } else { print ' <div class="error-alert"> <p>' . T_('Missing or invalid YouTube session token.') . '</p> </div>'; return false; } } try { $httpClient = Zend_Gdata_AuthSub::getHttpClient($token); } catch (Zend_Gdata_App_Exception $e) { print ' <div class="error-alert"> <p>' . T_('Could not connect to YouTube API. Your YouTube session token may be invalid.') . '</p> <p><i>' . $e->getMessage() . '</i></p> </div>'; return false; } $httpClient->setHeaders('X-GData-Key', 'key=' . $key); return $httpClient; }
/** * Shows a menu allowing the user to update an existing * recipe with the Base API update feature. * @return void */ function showEditMenu() { global $cuisines; $client = Zend_Gdata_AuthSub::getHttpClient($_POST['token']); $gdata = new Zend_Gdata_Gbase($client); try { $feed = $gdata->getGbaseItemFeed(ITEMS_FEED_URI); foreach ($feed->entries as $feed_entry) { $editLink = $feed_entry->link[2]->href; if ($editLink == $_POST['edit']) { $baseAttributeArr = $feed_entry->getGbaseAttribute('cooking_time'); if (isset($baseAttributeArr[0]) && is_object($baseAttributeArr[0])) { $splitCookingTime = explode(' ', $baseAttributeArr[0]->text); } $baseAttributeArr = $feed_entry->getGbaseAttribute('cuisine'); // Cuisine can have multiple entries if (isset($baseAttributeArr[0]) && is_object($baseAttributeArr[0])) { $cuisine = $baseAttributeArr[0]->text; } $baseAttributeArr = $feed_entry->getGbaseAttribute('serving_count'); // $serving_count can have multiple entries if (isset($baseAttributeArr[0]) && is_object($baseAttributeArr[0])) { $serving_count = $baseAttributeArr[0]->text; } $main_ingredient = $feed_entry->getGbaseAttribute('main_ingredient'); // Main_ingredient can have multiple entries if (is_array($main_ingredient)) { $main_ingredient = $main_ingredient[0]->text; } printHTMLHeader(); print '<table style="width:50%">' . "\n"; print '<tr>' . '<th colspan="2" style="text-align:center">Edit recipe:</th>' . '</tr>' . "\n"; print "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">\n" . '<input type="hidden" name="action" value="update">' . "\n" . '<input type="hidden" name="link" value="' . $_POST['edit'] . '">' . "\n" . '<input type="hidden" name="token" value="' . $_POST['token'] . '">' . "\n"; print '<tr><td align="right">Title:</td>' . "\n" . '<td>' . '<input type="text" name="recipe_title" class="half" value="' . $feed_entry->title->text . '">' . '</td></tr>' . "\n"; print '<tr><td align="right">Main ingredient:</td>' . "\n" . '<td><input type="text" name="main_ingredient" value="' . $main_ingredient . '" class="half"></td></tr>' . "\n"; print '<tr><td align="right">Cuisine:</td>' . "\n" . '<td><select name="cuisine" class="half">' . "\n"; foreach ($cuisines as $curCuisine) { print '<option value="' . $curCuisine . '"'; if ($curCuisine == $cuisine) { print ' selected="selected"'; } print '>' . $curCuisine . "</option>\n"; } print '</select></td></tr>' . "\n"; print '<tr><td align="right">Cooking Time:</td>' . '<td><input type="text" name="time_val" size="2" maxlength="2" ' . 'value="' . $splitCookingTime[0] . '"> ' . "\n" . '<select name="time_units">' . "\n"; if ($splitCookingTime[1] == "minutes") { print '<option value="minutes" selected="selected">minutes</option>' . "\n"; print '<option value="hours">hours</option>' . "\n"; } else { print '<option value="minutes">minutes</option>' . "\n"; print '<option value="hours" selected="selected">hours</option>' . "\n"; } print '</select></td></tr>' . "\n" . '<tr><td align="right">Serves:</td>' . "\n" . '<td><input type="text" name="serves" value="' . $serving_count . '" size="2" maxlength="3"></td></tr>' . "\n" . '<tr><td align="right">Recipe:</td>' . "\n" . '<td><textarea class="full" name="recipe_text">' . $feed_entry->content->text . '</textarea></td></tr>' . "\n" . '<td> </td><td><input type="submit" value="Update">' . '</td>' . "\n" . '</form></tr></table>' . "\n"; printHTMLFooter(); break; } } } catch (Zend_Gdata_App_Exception $e) { showMainMenu($e->getMessage(), $_POST['token']); } }
/** * @group ZF-11351 * @expectedException Zend_Gdata_App_HttpException */ public function testAuthSubGetHttpClientShouldThrowExceptionOnVanillaHttpClient() { $client = new Zend_Http_Client(); $client->setUri('http://example.com/AuthSub'); $gdclient = Zend_Gdata_AuthSub::getHttpClient('FakeToken', $client); $this->fail('Expected exception Zend_Gdata_App_HttpException not raised!'); }
public function testGetHttpClientProvidesNewClientWhenNullPassed() { $client = Zend_Gdata_AuthSub::getHttpClient($this->token); $this->assertTrue($client instanceof Zend_Gdata_HttpClient); $this->assertEquals($this->token, $client->getAuthSubToken()); }
function getAuthSubHttpClient($mmm_id, $username) { $httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); return $httpClient; }
function getAuthSubHttpClient($mmm_id, $username) { if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) { $this->redirect('/yts/index/'); exit; return false; } else { if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); $sessionToken = $_SESSION['sessionToken']; $this->time = time(); $this->record['Yt']['mmm_id'] = $mmm_id; $this->record['Yt']['sessionToken'] = $sessionToken; $this->record['Yt']['status'] = '1'; $this->record['Yt']['etime'] = $this->time; /*$qry="insert into yt_login(mmm_id , user_id ,sessionToken , status) values ('$mmm_id', '$username' , '$sessionToken', '1')"; $result = mysql_query($qry); */ } } $httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); return $httpClient; }
/** * setFormData * * Saves all the data passed in from the form upload. * * @param array $formData * * @return void */ public function setFormData($formData) { $this->formData = $formData; $token = getUserPicasaSessionToken($this->fcmsUser->id); $albumId = $formData['albums']; $user = $formData['picasa_user']; $httpClient = Zend_Gdata_AuthSub::getHttpClient($token); $picasaService = new Zend_Gdata_Photos($httpClient, "Google-DevelopersGuide-1.0"); $thumbSizes = '150c,600'; if ($this->usingFullSizePhotos) { $thumbSizes .= ',d'; } try { $query = new Zend_Gdata_Photos_AlbumQuery(); $query->setUser($user); $query->setAlbumId($albumId); $query->setParam('thumbsize', $thumbSizes); $albumFeed = $picasaService->getAlbumFeed($query); } catch (Zend_Gdata_App_Exception $e) { $this->fcmsError->add(array('type' => 'operation', 'message' => T_('Could not get Picasa data.'), 'error' => $e->getMessage(), 'file' => __FILE__, 'line' => __LINE__)); return false; } $this->albumFeed = $albumFeed; }
*/ $session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); $_SESSION['base_token'] = $session_token; } else { /** * Display a link to generate a single-use token. */ $googleUri = Zend_Gdata_AuthSub::getAuthSubTokenUri('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], $uri, 0, 1); echo "Click <a href='{$googleUri}'>here</a> to authorize this application."; exit; } } /** * Create an authenticated HTTP Client to talk to Google. */ $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['base_token']); /** * Submit query to Google Base */ $q = ''; if (isset($_GET['q']) && $_GET['q']) { $q = $_GET['q']; if (get_magic_quotes_gpc()) { $q = stripslashes($q); } $gdata = new Zend_Gdata_Base($client); $gdata->setQuery($q); $feed = $gdata->getBaseFeed(); } /** * Filter php_self to avoid a security vulnerability.
private function _getAuthSubClient() { if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) { $request = $this->getRequest(); $nextUrl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri(); $scope = 'http://www.google.com/base/feeds/items'; $secure = false; $session = true; $authSubUrl = Zend_Gdata_AuthSub::getAuthSubTokenUri($nextUrl, $scope, $secure, $session); header("HTTP/1.0 307 Temporary redirect"); header("Location: " . $authSubUrl); exit; } if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); } $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); return $client; }
public function action_import() { $this->template->content = "Muahhaa"; $my_calendar = 'http://www.google.com/calendar/feeds/default/private/full'; if (!isset($_SESSION['cal_token'])) { if (isset($_GET['token'])) { // You can convert the single-use token to a session token. $session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); // Store the session token in our session. $_SESSION['cal_token'] = $session_token; } else { // Display link to generate single-use token $url = url::site('admin/import', TRUE); $googleUri = Zend_Gdata_AuthSub::getAuthSubTokenUri($url, $my_calendar, 0, 1); $this->template->content = "Click <a href='{$googleUri}'>here</a> to authorize this application."; return; } } // Create an authenticated HTTP Client to talk to Google. $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['cal_token']); // Create a Gdata object using the authenticated Http Client $this->cal = new Zend_Gdata_Calendar($client); $this->template->content = ""; if (isset($_POST['selectedCalendar'])) { $_SESSION['selectedCal'] = $_POST['selectedCalendar']; } $this->_fetchCalendarCache(); $this->importSelectCal(); if ($_SESSION['selectedCal']) { $this->_fetchEventsCache($_SESSION['selectedCal']); $this->template->content .= View::factory('admin/import_calEvents', array('events' => $_SESSION['eventsCache'][$_SESSION['selectedCal']], 'existingRooms' => ORM::factory('room')->find_all()->as_array())); } }
/** * 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(); }