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


PHP Zend_Gdata_YouTube::updateEntry方法代码示例

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


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

示例1: update_element

 /**
  *
  * @param  string             $object
  * @param  string             $object_id
  * @param  array              $datas
  * @return Bridge_Api_Youtube
  */
 public function update_element($object, $object_id, array $datas)
 {
     $required_fields = ["description", "category", "tags", "title", "privacy"];
     foreach ($required_fields as $field) {
         if (!array_key_exists($field, $datas)) {
             throw new Bridge_Exception_ActionMandatoryField("Le paramétre " . $field . " est manquant");
         }
     }
     if (!$this->is_valid_object_id($object_id)) {
         throw new Bridge_Exception_ActionInvalidObjectId($object_id);
     }
     switch ($object) {
         case "video":
             $videoEntry = $this->_api->getFullVideoEntry($object_id);
             if ($videoEntry->getEditLink() === null) {
                 throw new Bridge_Exception_ActionForbidden("You cannot edit this video object");
             }
             $videoEntry->setVideoDescription(trim($datas['description']));
             $videoEntry->setVideoCategory(trim($datas['category']));
             $videoEntry->setVideoTags(trim($datas['tags']));
             $videoEntry->setVideoTitle(trim($datas['title']));
             if ($datas["privacy"] == "public") {
                 $videoEntry->setVideoPublic();
             } else {
                 $videoEntry->setVideoPrivate();
             }
             $this->_api->updateEntry($videoEntry, $videoEntry->getEditLink()->getHref());
             break;
         default:
             throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object);
             break;
     }
     return $this;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:41,代码来源:Youtube.php

示例2: editVideoData

/**
 * Update an existing video's meta-data.
 *
 * @param string $newVideoTitle The new title for the video entry.
 * @param string $newVideoDescription The new description for the video entry.
 * @param string $newVideoCategory The new category for the video entry.
 * @param string $newVideoTags The new set of tags for the video entry (whitespace separated).
 * @param string $videoId The video id for the video to be edited.
 * @return void
 */
function editVideoData($newVideoTitle, $newVideoDescription, $newVideoCategory, $newVideoTags, $videoId)
{
    $httpClient = getAuthSubHttpClient();
    $youTubeService = new Zend_Gdata_YouTube($httpClient);
    $feed = $youTubeService->getVideoFeed('http://gdata.youtube.com/feeds/users/default/uploads');
    $videoEntryToUpdate = null;
    foreach ($feed as $entry) {
        if ($entry->getVideoId() == $videoId) {
            $videoEntryToUpdate = $entry;
            break;
        }
    }
    if (!$videoEntryToUpdate instanceof Zend_Gdata_YouTube_VideoEntry) {
        print 'ERROR - Could not find a video entry with id ' . $videoId . '<br />' . printCacheWarning();
        return;
    }
    try {
        $putUrl = $videoEntryToUpdate->getEditLink()->getHref();
    } catch (Zend_Gdata_App_Exception $e) {
        print 'ERROR - Could not obtain video entry\'s edit link: ' . $e->getMessage() . '<br />';
        return;
    }
    $videoEntryToUpdate->setVideoTitle($newVideoTitle);
    $videoEntryToUpdate->setVideoDescription($newVideoDescription);
    $videoEntryToUpdate->setVideoCategory($newVideoCategory);
    // convert tags from space separated to comma separated
    $videoTagsArray = explode(' ', trim($newVideoTags));
    // strip out empty array elements
    foreach ($videoTagsArray as $key => $value) {
        if (strlen($value) < 2) {
            unset($videoTagsArray[$key]);
        }
    }
    $videoEntryToUpdate->setVideoTags(implode(', ', $videoTagsArray));
    try {
        $updatedEntry = $youTubeService->updateEntry($videoEntryToUpdate, $putUrl);
        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 post video meta-data: ' . $e->getMessage();
        return;
    }
    print 'Entry updated successfully.<br /><a href="#" onclick="' . 'ytVideoApp.presentFeed(\'search_owner\', 5, 0, \'none\'); ' . 'ytVideoApp.refreshSearchResults();" >' . '(refresh your video listing)</a><br />' . printCacheWarning();
}
开发者ID:holdensmagicalunicorn,项目名称:copperFramework,代码行数:59,代码来源:operations.php

示例3: editAction

		function editAction()
		{
			if ($_SESSION['role_id']!=0)
			{
				$this->_redirect($this->view->baseUrl().'/../admin/uploadvideo');
			}
			else 
			{
				$this->view->headTitle('UNC - Admin website');
				$this->view->headLink()->appendStylesheet($this->view->baseUrl().'/application/templates/admin/css/layout.css');
				$this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/admin/js/jquery-1.7.2.min.js','text/javascript');
				$this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/admin/js/hideshow.js','text/javascript');
				
				$video_id = $this->_request->getParam('video_id');
				$video_link = $this->mVideo->getVideoLinkById($video_id);
				$this->view->role = $this->role;
				$info = $this->mVideo->getVideoById($video_id);
				$form = $this->formInsert();
				$this->view->listCategoryId = explode(",", $info['category_id']);
				$this->view->listCategory = $this->mVideo->getListVideoCategory();
				
				if($this->role=="0" | ($this->role=="1" & $this->user_login==$info['user_upload']))
				{
					$form->setAction($this->view->baseUrl().'/admin/uploadvideo/edit/video_id/'.$video_id);
					
					$form->getElement('link')->setValue($info['video_full_link']);
					$form->getElement('title')->setValue($info['video_title']);
					$form->getElement('description')->setValue($info['video_description']);
					$form->getElement('is_active')->setValue($info['is_active']);
					
					$this->view->form = $form;
					$this->view->title = 'Sửa thông tin video';		
					
					if($this->_request->isPost())
					{
						$listCategoryId = "";
						foreach($_POST['checkbox'] as $check)
						{
							if($listCategoryId == "")
										$listCategoryId = $check;
							else $listCategoryId = $listCategoryId.','.$check;
						}
						$listCategoryId = str_replace("", "", $listCategoryId);
										
						if($form->isValid($_POST))
						{
							if($video_link != null)
							{
								$input = array(
									'video_link'			=> $video_link,
									'video_title'			=> $form->getValue('title'),
									'video_description'		=> $form->getValue('description'),
									'is_active'				=> $form->getValue('is_active'),
									'category_id'			=> $listCategoryId
								);	
								
								if($this->mVideo->editVideo($input))
								{
									$_SESSION['result']='Cập nhật thành công';
								}
								
								$youtube_id = $this->mVideo->getYouTubeIdByVideoId($video_id);
								$account = $this->mVideo->getAccountByYoutubeId($youtube_id);
								$user = $account['youtube_username'];
								$pass = $account['password'];
								
								try 
								{
									$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
									Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
									$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
													              $username = $user,
													              $password = $pass,
													              $service 	= 'youtube',
													              $client 	= null,
													              $source 	= 'NIWApp', 
													              $loginToken 	= null,
													              $loginCaptcha = null,
													              $authenticationURL
													           );
									Zend_Loader::loadClass('Zend_Gdata_YouTube');
								 	$yt = new Zend_Gdata_YouTube($httpClient, 'NIW-App-1.0', '661085061264.apps.googleusercontent.com', 'AI39si4UPUxw1FE5hqSi0Z-B-5z3PIVovbBWKmqiMI3cXJ7lhvjJcABV-eqimb2EeSiuedWK8N9OGOdB1namX1CqqYki8jEfSQ');
									$video = $yt->getFullVideoEntry($input['video_link']);
					                		$putUrl = $video->getEditLink()->getHref(); 
									$video->setVideoTitle($input['video_title']);
									$video->setVideoDescription($input['video_description']);
					                $yt->updateEntry($video, $putUrl);
							    }
							    catch (Exception $ex) {
							        echo $ex->getMessage();
							        exit;
							    }
								 
								$this->_redirect($this->view->baseUrl().'/../admin/uploadvideo');
							}
							else
							{
								$input = $this->_getInput($form,$listCategoryId);
								if ($this->mVideo->updateVideo($video_id,$input))
								{
//.........这里部分代码省略.........
开发者ID:hungnv0789,项目名称:vhtm,代码行数:101,代码来源:UploadvideoController.php


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