本文整理汇总了PHP中Zend_Gdata_AuthSub::getHttpClient方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_AuthSub::getHttpClient方法的具体用法?PHP Zend_Gdata_AuthSub::getHttpClient怎么用?PHP Zend_Gdata_AuthSub::getHttpClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_AuthSub
的用法示例。
在下文中一共展示了Zend_Gdata_AuthSub::getHttpClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthSubHttpClient
function getAuthSubHttpClient()
{
if (isset($_SESSION['google_session_token'])) {
$client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['google_session_token']);
return $client;
}
}
示例2: includes
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'));
}
示例3: comment
function comment($entry, $comment)
{
$username = $_SESSION['username'];
$query = "select token from user where username='{$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;
}
}
示例4: getAjaxPicasaAlbums
/**
* 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>';
}
示例5: Zend_Gdata_YouTube
// 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>
示例6: 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;
}
示例7: getAuthSubHttpClient
/**
* 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;
}
示例8: str_repeat
} 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();
示例9: 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());
}
示例10: 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'));
}
示例11: _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;
*/
}
示例12: get_youtube_httpclient
/**
* 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;
}
示例13: addUsername
/**
* 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']}");
}
示例14: 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";
//.........这里部分代码省略.........
示例15: getYouTubeAuthSubHttpClient
/**
* 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;
}