本文整理汇总了PHP中Zend_Gdata_YouTube_VideoEntry::setExtensionElements方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube_VideoEntry::setExtensionElements方法的具体用法?PHP Zend_Gdata_YouTube_VideoEntry::setExtensionElements怎么用?PHP Zend_Gdata_YouTube_VideoEntry::setExtensionElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_YouTube_VideoEntry
的用法示例。
在下文中一共展示了Zend_Gdata_YouTube_VideoEntry::setExtensionElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_youtube_uploadform
public function fetch_youtube_uploadform($yt, $videotitle, $videodescription)
{
global $CFG, $USER;
// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoTitle($videotitle);
$myVideoEntry->setVideoDescription($videodescription);
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Education');
//This sets videos private, but then can't view if not logged in as the account owner
//$myVideoEntry->setVideoPrivate();
//So instead we set them to unlisted(but its more complex)
$unlisted = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
$unlisted->setExtensionAttributes(array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied')));
$myVideoEntry->setExtensionElements(array($unlisted));
// Set keywords. This must be a comma-separated string
// Individual keywords cannot contain whitespace
// We are not doing this, but it would be possible
//$myVideoEntry->SetVideoTags('cars, funny');
//data is all set, so we get our upload token from google
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
//Set the URL YouTube should redirect user to after upload
//that will be the same iframe
$nextUrl = $CFG->httpswwwroot . '/mod/assign/submission/youtube/uploader.php';
// Now that we have the token, we build the form
$form = '<form action="' . $postUrl . '?nexturl=' . $nextUrl . '" method="post" enctype="multipart/form-data">' . '<input name="file" type="file"/>' . '<input name="token" type="hidden" value="' . $tokenValue . '"/>' . '<input value="Upload Video File" type="submit" onclick="document.getElementById(\'id_uploadanim\').style.display=\'block\';" />' . '</form>';
// We tag on a hidden uploading icon. YouTube gives us no progress events, sigh.
// So its the best we can do to show an animated gif.
// But if it fails, user will wait forever.
$form .= '<img id="id_uploadanim" style="display: none;margin-left: auto;margin-right: auto;" src="' . $CFG->httpswwwroot . '/mod/assign/submission/youtube/pix/uploading.gif"/>';
return $form;
}
示例2: displayYouTubeUploadFilePage
/**
* displayYouTubeUploadFilePage
*
* Takes the post data from the previous form, sends to youtube, creates new entry,
* and prints the video file upload form.
*
* @return void
*/
function displayYouTubeUploadFilePage()
{
$this->displayHeader();
$videoTitle = '';
$videoDescription = '';
if (isset($_POST['title'])) {
$videoTitle = strip_tags($_POST['title']);
}
if (isset($_POST['description'])) {
$videoDescription = strip_tags($_POST['description']);
}
$videoCategory = isset($_POST['category']) ? $_POST['category'] : '';
$videoUnlisted = isset($_POST['unlisted']) ? true : false;
// Create fcms video - we update after the youtube video is created
$sql = "INSERT INTO `fcms_video` (\n `source_id`, \n `title`, \n `description`, \n `source`, \n `created`, \n `created_id`, \n `updated`, \n `updated_id`\n )\n VALUES\n ('0', ?, ?, 'youtube', NOW(), ?, NOW(), ?)";
$params = array($videoTitle, $videoDescription, $this->fcmsUser->id, $this->fcmsUser->id);
$lastId = $this->fcmsDatabase->insert($sql, $params);
if ($lastId === false) {
$this->fcmsError->displayError();
$this->displayFooter();
return;
}
// Save fcms video id
$_SESSION['fcmsVideoId'] = $lastId;
$sessionToken = $this->getSessionToken($this->fcmsUser->id);
$youtubeConfig = getYouTubeConfigData();
$httpClient = getYouTubeAuthSubHttpClient($youtubeConfig['youtube_key'], $sessionToken);
if ($httpClient === false) {
// Error message was already displayed by getYouTubeAuthSubHttpClient()
$this->displayFooter();
die;
}
$youTubeService = new Zend_Gdata_YouTube($httpClient);
$newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$newVideoEntry->setVideoTitle($videoTitle);
$newVideoEntry->setVideoDescription($videoDescription);
$newVideoEntry->setVideoCategory($videoCategory);
// make video unlisted
if ($videoUnlisted) {
$unlisted = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
$unlisted->setExtensionAttributes(array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied')));
$newVideoEntry->setExtensionElements(array($unlisted));
}
try {
$tokenArray = $youTubeService->getFormUploadToken($newVideoEntry, 'http://gdata.youtube.com/action/GetUploadToken');
} catch (Exception $e) {
echo '
<div class="error-alert">
<p>' . T('Could not retrieve token for syndicated upload.') . '</p>
<p>' . $e->getMessage() . '</p>
</div>';
$this->displayFooter();
return;
}
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
$nextUrl = getDomainAndDir() . 'video.php?upload=youtube';
echo '
<form action="' . $postUrl . '?nexturl=' . $nextUrl . '" method="post" enctype="multipart/form-data">
<fieldset>
<legend><span>' . T_('Upload YouTube Video') . '</span></legend>
<div class="field-row">
<div class="field-label"><label><b>' . T_('Title') . '</b></label></div>
<div class="field-widget"><b>' . $videoTitle . '</b></div>
</div>
<div class="field-row">
<div class="field-label"><label><b>' . T_('Video') . '</b></label></div>
<div class="field-widget">
<input type="file" name="file" size="50"/>
</div>
</div>
<input name="token" type="hidden" value="' . $tokenValue . '"/>
<input class="sub1" type="submit" id="upload_file" name="upload_file" value="' . T_('Upload') . '"/>
</fieldset>
</form>';
$this->displayFooter();
}