本文整理汇总了PHP中Zend_Gdata_AuthSub::getAuthSubSessionToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_AuthSub::getAuthSubSessionToken方法的具体用法?PHP Zend_Gdata_AuthSub::getAuthSubSessionToken怎么用?PHP Zend_Gdata_AuthSub::getAuthSubSessionToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_AuthSub
的用法示例。
在下文中一共展示了Zend_Gdata_AuthSub::getAuthSubSessionToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupDocsClient
function setupDocsClient($token = null)
{
global $authSubURL;
$docsClient = null;
// Fetch a new AuthSub token?
if (!$token && !isset($_SESSION['sessionToken'])) {
$next = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$scope = 'http://docs.google.com/feeds/ https://docs.google.com/feeds/';
$secure = 0;
$session = 1;
$permission = 1;
// 1 - allows posting notices && allows reading profile data
$authSubURL = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);
} else {
if (isset($_SESSION['sessionToken'])) {
$httpClient = new Zend_Gdata_HttpClient();
$httpClient->setAuthSubToken($_SESSION['sessionToken']);
$docsClient = new Zend_Gdata_Docs($httpClient, 'google-OCRPHPDemo-v0.1');
} else {
$httpClient = new Zend_Gdata_HttpClient();
$_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken(trim($token), $httpClient);
$httpClient->setAuthSubToken($_SESSION['sessionToken']);
$docsClient = new Zend_Gdata_Docs($httpClient, 'google-OCRPHPDemo-v0.1');
}
}
return $docsClient;
}
示例2: updateAuthSubToken
/**
* Upgrade the single-use token to a session token.
*
* @param string $singleUseToken A valid single use token that is upgradable to a session token.
* @return void
*/
function updateAuthSubToken($singleUseToken)
{
try {
$sessionToken = Zend_Gdata_AuthSub::getAuthSubSessionToken($singleUseToken);
} catch (Zend_Gdata_App_Exception $e) {
print 'ERROR - Token upgrade for ' . $singleUseToken . ' failed : ' . $e->getMessage();
return;
}
$_SESSION['sessionToken'] = $sessionToken;
header('Location: ' . HOME_URL);
}
示例3: getAuthSubHttpClient
/**
* 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;
$client = new Zend_Gdata_HttpClient();
if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) {
$_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token'], $client);
}
if (empty($_SESSION['sessionToken'])) {
return null;
}
$client->setAuthSubToken($_SESSION['sessionToken']);
return $client;
}
示例4: getAuthSubHttpClient
/**
* 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
*/
public function getAuthSubHttpClient()
{
global $_SESSION, $_GET, $_authSubKeyFile, $_authSubKeyFilePassphrase;
$client = new Zend_Gdata_HttpClient();
if ($_authSubKeyFile != null) {
// set the AuthSub key
$client->setAuthSubPrivateKeyFile($_authSubKeyFile, $_authSubKeyFilePassphrase, true);
}
if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) {
$_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token'], $client);
}
$client->setAuthSubToken($_SESSION['sessionToken']);
return $client;
}
示例5: getAuthSubHttpClient
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;
}
示例6: testAuthSubSessionTokenCatchesHttpClientException
/**
* @expectedException Zend_Gdata_App_HttpException
*/
public function testAuthSubSessionTokenCatchesHttpClientException()
{
$adapter = new Zend_Http_Client_Adapter_Test();
$adapter->setNextRequestWillFail(true);
$client = new Zend_Gdata_HttpClient();
$client->setUri('http://example.com/AuthSub');
$client->setAdapter($adapter);
$newtok = Zend_Gdata_AuthSub::getAuthSubSessionToken($this->token, $client);
}
示例7: googleAction
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());
}
示例8: gCalDemo
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";
//.........这里部分代码省略.........
示例9: getAuthSubHttpClient
/**
* 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;
}
示例10: authenticate
function authenticate($singleUseToken = null)
{
$sessionToken = isset($_SESSION['sessionToken']) ? $_SESSION['sessionToken'] : null;
// If there is no AuthSub session or one-time token waiting for us,
// redirect the user to Google Health's AuthSub handler to get one.
if (!$sessionToken && !$singleUseToken) {
$next = getCurrentUrl();
$secure = 1;
$session = 1;
$authSubHandler = 'https://www.google.com/h9/authsub';
$permission = 1;
// 1 - allows reading of the profile && posting notices
$authSubURL = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, SCOPE, $secure, $session, $authSubHandler);
$authSubURL .= '&permission=' . $permission;
echo '<a href="' . $authSubURL . '">Link your Google Health Account</a>';
exit;
}
$client = new Zend_Gdata_HttpClient();
$client->setAuthSubPrivateKeyFile(HEALTH_PRIVATE_KEY, null, true);
// Convert an AuthSub one-time token into a session token if needed
if ($singleUseToken && !$sessionToken) {
$sessionToken = Zend_Gdata_AuthSub::getAuthSubSessionToken($singleUseToken, $client);
$_SESSION['sessionToken'] = $sessionToken;
}
$client->setAuthSubToken($sessionToken);
return $client;
}
示例11: session_start
<?php
session_start();
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_Photos');
//Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
if (isset($_GET['token'])) {
$_SESSION['google_session_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
$params = "";
foreach ($_GET as $key => $value) {
$params = $params . $key . '=' . $value . '&';
}
//$params = $params . 'ajax=';
$params = rtrim($params, '&');
header("location:../download_album.php?" . $params);
}
?>
<html>
<head>
<title>Facebook Album</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="resources/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="resources/css/bootstrap.min.css" />
<style>
#login-div {
text-align: center;
margin-top: 15%;
示例12: _getAuthSubClient
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;
}
示例13: getCurrentUrl
// Parameters to give to AuthSub server
$next = getCurrentUrl();
$scope = GoogleCalendarInterface::GCAL_INTEGRATION_SCOPE;
$secure = false;
$session = true;
// Redirect the user to the AuthSub server to sign in
$authSubUrl = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);
header("HTTP/1.0 307 Temporary redirect");
header("Location: " . $authSubUrl);
exit;
} else {
try {
$client = new Zend_Gdata_HttpClient();
$pathToKey = sfConfig::get('sf_root_dir') . '/' . sfConfig::get('app_googleCalendarIntegration_privateKeyPath');
$client->setAuthSubPrivateKeyFile($pathToKey, null, true);
$sessionToken = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token'], $client);
} catch (Exception $e) {
sfErrorNotifier::alert("Google Calendar Init: " . $e->getMessage());
$this->redirect('default', array('module' => 'googleCalendarIntegration', 'action' => 'step3Error'));
}
$redirectUrl = '';
if ($sessionToken) {
$loggedInUser = PcUserPeer::getLoggedInUser();
if ($loggedInUser) {
$googleCalendarInterface = new GoogleCalendarInterface($loggedInUser);
$googleCalendarInterface->resetDbEntry();
$googleCalendarInterface->setSessionToken($sessionToken);
}
$configuration->loadHelpers('Url');
$redirectUrl = 'http://' . sfConfig::get('app_site_url') . '/' . sfConfig::get('app_accountApp_frontController') . '/googleCalendarIntegration/step3';
} else {
示例14: getAuthSubHttpClient
/**
* 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'));
}
示例15: _getAuthSubHttpClient
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;
*/
}