本文整理匯總了PHP中Zend_Gdata_YouTube::getUserProfile方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Gdata_YouTube::getUserProfile方法的具體用法?PHP Zend_Gdata_YouTube::getUserProfile怎麽用?PHP Zend_Gdata_YouTube::getUserProfile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Gdata_YouTube
的用法示例。
在下文中一共展示了Zend_Gdata_YouTube::getUserProfile方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_user_name
/**
*
* @return string
*/
public function get_user_name()
{
return $this->_api->getUserProfile('default')->getUsername();
}
示例2: 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']}");
}
示例3:
$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>
<?php
}
?>
</div>
示例4: displayYouTubeUploadPage
/**
* displayYouTubeUploadPage
*
* @return void
*/
function displayYouTubeUploadPage()
{
$this->displayHeader();
$this->checkUserAuthedYouTube();
$youtubeConfig = getYouTubeConfigData();
$httpClient = getYouTubeAuthSubHttpClient($youtubeConfig['youtube_key']);
if ($httpClient === false) {
// Error message was already displayed by getYouTubeAuthSubHttpClient()
$this->displayFooter();
die;
}
$youTubeService = new Zend_Gdata_YouTube($httpClient);
$feed = $youTubeService->getUserProfile('default');
if (!$feed instanceof Zend_Gdata_YouTube_UserProfileEntry) {
print '
<div class="error-alert">' . T_('Could not get YouTube data for user.') . '</div>';
return;
}
$username = $feed->getUsername();
echo '
<form action="video.php?upload=youtube" method="post">
<fieldset>
<legend><span>' . T_('Upload YouTube Video') . '</span></legend>
<div class="field-row">
<div class="field-label"><label><b>' . T_('YouTube Account') . '</b></label></div>
<div class="field-widget">' . $username . '
</div>
</div>
<div class="field-row">
<div class="field-label"><label><b>' . T_('Title') . '</b></label></div>
<div class="field-widget">
<input type="text" name="title" size="50"/>
</div>
</div>
<div class="field-row">
<div class="field-label"><label><b>' . T_('Description') . '</b></label></div>
<div class="field-widget">
<textarea cols="50" name="description"></textarea>
</div>
</div>
<div class="field-row">
<div class="field-label"><label><b>' . T_('Category') . '</b></label></div>
<div class="field-widget">
<select name="category">
<option value="Autos">' . T_('Autos & Vehicles') . '</option>
<option value="Music">' . T_('Music') . '</option>
<option value="Animals">' . T_('Pets & Animals') . '</option>
<option value="Sports">' . T_('Sports') . '</option>
<option value="Travel">' . T_('Travel & Events') . '</option>
<option value="Games">' . T_('Gadgets & Games') . '</option>
<option value="Comedy">' . T_('Comedy') . '</option>
<option value="People">' . T_('People & Blogs') . '</option>
<option value="News">' . T_('News & Politics') . '</option>
<option value="Entertainment">' . T_('Entertainment') . '</option>
<option value="Education">' . T_('Education') . '</option>
<option value="Howto">' . T_('Howto & Style') . '</option>
<option value="Nonprofit">' . T_('Nonprofit & Activism') . '</option>
<option value="Tech">' . T_('Science & Technology') . '</option>
</select>
</div>
</div>
<div class="field-row">
<div class="field-label"><label for="unlisted"><b>' . T_('Unlisted') . '</b></label></div>
<div class="field-widget">
<input type="checkbox" name="unlisted" id="unlisted_" value="yes" checked="checked"><br/>
<small>' . T_('"Unlisted" means that only people who know the link to the video can view it. The video will not appear in any of YouTube\'s public spaces, such as search results, your channel, or the Browse page, but the link can be shared with anyone.') . '</small>
</div>
</div>
<input class="sub1" type="submit" id="upload_data" name="upload_data" value="' . T_('Next') . '"/>
' . T_('or') . '
<a href="video.php">' . T_('Cancel') . '</a>
</fieldset>
</form>';
$this->displayFooter();
}
示例5: getAccountInfo
/**
* Retrieves a user's profile as an entry
*
* @param string $user The username of interest
* @return Zend_Gdata_YouTube_UserProfileEntry The user profile entry
*/
public function getAccountInfo($username)
{
return $this->yt->getUserProfile($username);
}
示例6: displayEditYouTube
/**
* displayEditYouTube
*
* @return void
*/
function displayEditYouTube()
{
$this->displayHeader();
$config = getYouTubeConfigData();
$user = getYouTubeUserData($this->fcmsUser->id);
// Setup url for callbacks
$callbackUrl = getDomainAndDir();
$callbackUrl .= 'settings.php?view=youtube';
if (!empty($config['youtube_key'])) {
if (!empty($user['youtube_session_token'])) {
$httpClient = getYouTubeAuthSubHttpClient($config['youtube_key'], $user['youtube_session_token']);
$youTubeService = new Zend_Gdata_YouTube($httpClient);
$feed = $youTubeService->getUserProfile('default');
if (!$feed instanceof Zend_Gdata_YouTube_UserProfileEntry) {
print '
<div class="error-alert">' . T_('Could not get YouTube data for user.') . '</div>';
return;
}
$username = $feed->getUsername();
$user = '<a href="http://www.youtube.com/user/' . $username . '">' . $username . '</a>';
$status = sprintf(T_('Currently connected as: %s'), $user);
$link = '<a class="disconnect" href="?revoke=youtube">' . T_('Disconnect') . '</a>';
} else {
$url = Zend_Gdata_AuthSub::getAuthSubTokenUri($callbackUrl, 'http://gdata.youtube.com', 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/youtube.png" alt="YouTube"/>
<h2>YouTube</h2>
<p>' . T_('YouTube allows users to discover, watch and share videos.') . '</p>
<div class="status">' . $status . '</div>
<div class="action">' . $link . '</div>
</div>';
$this->displayFooter();
}