当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Gdata_YouTube::getFormUploadToken方法代码示例

本文整理汇总了PHP中Zend_Gdata_YouTube::getFormUploadToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube::getFormUploadToken方法的具体用法?PHP Zend_Gdata_YouTube::getFormUploadToken怎么用?PHP Zend_Gdata_YouTube::getFormUploadToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Gdata_YouTube的用法示例。


在下文中一共展示了Zend_Gdata_YouTube::getFormUploadToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: browserBasedUpload

 function browserBasedUpload($username, $password, $source, $title, $des = '', $cate = 'Entertainment')
 {
     // Note that this example creates an unversioned service object.
     // You do not need to specify a version number to upload content
     // since the upload behavior is the same for all API versions.
     $httpClient = $this->clientLogin($username, $password, $source);
     $yt = new Zend_Gdata_YouTube($httpClient);
     // create a new VideoEntry object
     $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
     $myVideoEntry->setVideoTitle($title);
     $myVideoEntry->setVideoDescription($des);
     // The category must be a valid YouTube category!
     $myVideoEntry->setVideoCategory($cate);
     // Set keywords. Please note that this must be a comma-separated string
     // and that individual keywords cannot contain whitespace
     $myVideoEntry->SetVideoTags('cars, funny');
     $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
     try {
         $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
         return $tokenArray;
     } catch (Zend_Gdata_App_HttpException $httpException) {
         echo $httpException->getRawResponseBody();
     } catch (Zend_Gdata_App_Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:hoanglannet,项目名称:copar,代码行数:26,代码来源:zendyoutube.php

示例2: actionFormData

 /**
  * Prints a JSON with URL for form action and the needed token, and dies.<br />
  * Used with JSON POST requests.<br />
  * <p>Asks for the following POST fields:
  * <ul>
  *		<li>title</li>
  *		<li>description</li>
  *		<li>category (only one)</li>
  *		<li>keywords (comma-separated)</li>
  * </ul>
  * </p>
  * @return JSON
  */
 public function actionFormData()
 {
     Yii::import('system.collections.*');
     Yii::import('system.base.*');
     Yii::import('ext.*');
     Yii::import('ext.Zend.Gdata.*');
     require_once 'Zend/Loader.php';
     Yii::registerAutoloader(array('Zend_Loader', 'loadClass'));
     $login = Zend_Gdata_ClientLogin::getHttpClient($this->youtubeLogin, $this->youtubePassword, 'youtube', null, Yii::app()->name);
     $login->setHeaders('X-GData-Key', 'key=' . $this->youtubeDevKey);
     $utub = new Zend_Gdata_YouTube($login);
     $video = new Zend_Gdata_YouTube_VideoEntry();
     $media = $utub->newMediaGroup();
     $media->title = $utub->newMediaTitle()->setText($_POST['title']);
     $media->description = $utub->newMediaDescription()->setText($_POST['description']);
     $media->keywords = $utub->newMediaKeywords()->setText($_POST['keywords']);
     $media->category = array($utub->newMediaCategory()->setText($_POST['category'])->setScheme(self::CAT_SCHEME), $utub->newMediaCategory()->setText(preg_replace('/\\s/', '', Yii::app()->name) . 'Site')->setScheme(self::TAG_SCHEME));
     $video->mediaGroup = $media;
     $data = $utub->getFormUploadToken($video);
     exit(json_encode($data));
 }
开发者ID:nurirahmat,项目名称:Yii-Extensions,代码行数:34,代码来源:YouTubeUploader.php

示例3: createUploadForm

/**
 * Create upload form by sending the incoming video meta-data to youtube and
 * retrieving a new entry. Prints form HTML to page.
 *
 * @param string $VideoTitle The title for the video entry.
 * @param string $VideoDescription The description for the video entry.
 * @param string $VideoCategory The category for the video entry.
 * @param string $VideoTags The set of tags for the video entry (whitespace separated).
 * @param string $nextUrl (optional) The URL to redirect back to after form upload has completed.
 * @return void
 */
function createUploadForm($videoTitle, $videoDescription, $videoCategory, $videoTags, $nextUrl = null)
{
    $httpClient = getAuthSubHttpClient();
    $youTubeService = new Zend_Gdata_YouTube($httpClient);
    $newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
    $newVideoEntry->setVideoTitle($videoTitle);
    $newVideoEntry->setVideoDescription($videoDescription);
    //make sure first character in category is capitalized
    $videoCategory = strtoupper(substr($videoCategory, 0, 1)) . substr($videoCategory, 1);
    $newVideoEntry->setVideoCategory($videoCategory);
    // convert videoTags from whitespace separated into comma separated
    $videoTagsArray = explode(' ', trim($videoTags));
    $newVideoEntry->setVideoTags(implode(', ', $videoTagsArray));
    $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
    try {
        $tokenArray = $youTubeService->getFormUploadToken($newVideoEntry, $tokenHandlerUrl);
        if (loggingEnabled()) {
            logMessage($httpClient->getLastRequest(), 'request');
            logMessage($httpClient->getLastResponse()->getBody(), 'response');
        }
    } catch (Zend_Gdata_App_HttpException $httpException) {
        print 'ERROR ' . $httpException->getMessage() . ' HTTP details<br /><textarea cols="100" rows="20">' . $httpException->getRawResponseBody() . '</textarea><br />' . '<a href="session_details.php">' . 'click here to view details of last request</a><br />';
        return;
    } catch (Zend_Gdata_App_Exception $e) {
        print 'ERROR - Could not retrieve token for syndicated upload. ' . $e->getMessage() . '<br /><a href="session_details.php">' . 'click here to view details of last request</a><br />';
        return;
    }
    $tokenValue = $tokenArray['token'];
    $postUrl = $tokenArray['url'];
    // place to redirect user after upload
    if (!$nextUrl) {
        $nextUrl = $_SESSION['homeUrl'];
    }
    print <<<END
        <br /><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" />
        </form>
END;
}
开发者ID:holdensmagicalunicorn,项目名称:copperFramework,代码行数:53,代码来源:operations.php

示例4: getAuthSubHttpClient

$videoTags = null;
$nextUrl = null;
$httpClient = getAuthSubHttpClient();
$youTubeService = new Zend_Gdata_YouTube($httpClient);
$newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$newVideoEntry->setVideoTitle($videoTitle);
$newVideoEntry->setVideoDescription($videoDescription);
//make sure first character in category is capitalized
$videoCategory = strtoupper(substr($videoCategory, 0, 1)) . substr($videoCategory, 1);
$newVideoEntry->setVideoCategory($videoCategory);
// convert videoTags from whitespace separated into comma separated
$videoTagsArray = explode(' ', trim($videoTags));
$newVideoEntry->setVideoTags(implode(', ', $videoTagsArray));
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
try {
    $tokenArray = $youTubeService->getFormUploadToken($newVideoEntry, $tokenHandlerUrl);
    if (loggingEnabled()) {
        logMessage($httpClient->getLastRequest(), 'request');
        logMessage($httpClient->getLastResponse()->getBody(), 'response');
    }
} catch (Zend_Gdata_App_HttpException $httpException) {
    print 'ERROR ' . $httpException->getMessage() . ' HTTP details<br /><textarea cols="100" rows="20">' . $httpException->getRawResponseBody() . '</textarea><br />' . '<a href="session_details.php">' . 'click here to view details of last request</a><br />';
    return;
} catch (Zend_Gdata_App_Exception $e) {
    print 'ERROR - Could not retrieve token for syndicated upload. ' . $e->getMessage() . '<br /><a href="session_details.php">' . 'click here to view details of last request</a><br />';
    return;
}
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
// place to redirect user after upload
if (!$nextUrl) {
开发者ID:schematical,项目名称:MJax2.0,代码行数:31,代码来源:youtubeUploader_iframe.php

示例5: 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();
 }
开发者ID:sauravpratihar,项目名称:fcms,代码行数:85,代码来源:video.php


注:本文中的Zend_Gdata_YouTube::getFormUploadToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。