本文整理汇总了PHP中Zend_Gdata_YouTube_VideoEntry::setVideoTags方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube_VideoEntry::setVideoTags方法的具体用法?PHP Zend_Gdata_YouTube_VideoEntry::setVideoTags怎么用?PHP Zend_Gdata_YouTube_VideoEntry::setVideoTags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_YouTube_VideoEntry
的用法示例。
在下文中一共展示了Zend_Gdata_YouTube_VideoEntry::setVideoTags方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$published = new Zend_Gdata_App_Extension_Published("2011-10-21 12:00:00");
$updated = new Zend_Gdata_App_Extension_Updated("2011-10-21 12:20:00");
$id = new Zend_Gdata_App_Extension_Id("Az2cv12");
$rating = new Zend_Gdata_Extension_Rating(4, 1, 5, 200, 4);
$duration = new Zend_Gdata_YouTube_Extension_Duration(80);
$player = new Zend_Gdata_Media_Extension_MediaPlayer();
$player->setUrl("coucou");
$stat = new Zend_Gdata_YouTube_Extension_Statistics();
$stat->setViewCount("5");
$thumb = new Zend_Gdata_Media_Extension_MediaThumbnail('une url', '120', '90');
$media = new Zend_Gdata_YouTube_Extension_MediaGroup();
$media->setPlayer([$player]);
$media->setDuration($duration);
$media->setVideoId($id);
$media->setThumbnail([$thumb]);
$entry = new Zend_Gdata_YouTube_VideoEntry();
$entry->setMajorProtocolVersion(2);
$entry->setMediaGroup($media);
$entry->setStatistics($stat);
$entry->setRating($rating);
$entry->setVideoCategory("category");
$entry->setVideoDescription("one description");
$entry->setVideoPrivate();
$entry->setVideoTags(['tags']);
$entry->setVideoTitle("hellow");
$entry->setUpdated($updated);
$entry->setPublished($published);
$this->object = new Bridge_Api_Youtube_Element($entry, 'video');
}
示例2: 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;
}
示例3: uploadVideo
public function uploadVideo($fileDisk, $fileUrl, $props, $private = false)
{
// foreach ($props as $key => $val)
// {
// error_log($key . " is " . $val);
// }
// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $this->yt->newMediaFileSource($fileDisk);
$filesource->setContentType('video/quicktime');
// print_r($filesource);
// set slug header
$filesource->setSlug($fileUrl);
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($props['title']);
$myVideoEntry->setVideoDescription($props['description']);
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory($props['category']);
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->setVideoTags($props['keywords']);
if ($private) {
$myVideoEntry->setVideoPrivate();
} else {
$myVideoEntry->setVideoPublic();
}
$access = array();
$access[] = new Zend_Gdata_YouTube_Extension_Access('comment', $props['comment']);
$access[] = new Zend_Gdata_YouTube_Extension_Access('rate', $props['rate']);
$access[] = new Zend_Gdata_YouTube_Extension_Access('commentVote', $props['commentVote']);
$access[] = new Zend_Gdata_YouTube_Extension_Access('videoRespond', $props['videoRespond']);
$access[] = new Zend_Gdata_YouTube_Extension_Access('embed', $props['embed']);
$myVideoEntry->setAccess($access);
// set some developer tags -- this is optional
// (see Searching by Developer Tags for more details)
// $myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag'));
// set the video's location -- this is also optional
// $yt->registerPackage('Zend_Gdata_Geo');
// $yt->registerPackage('Zend_Gdata_Geo_Extension');
// $where = $yt->newGeoRssWhere();
// $position = $yt->newGmlPos('37.0 -122.0');
// $where->point = $yt->newGmlPoint($position);
// $myVideoEntry->setWhere($where);
// upload URI for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
// try to upload the video, catching a Zend_Gdata_App_HttpException,
// if available, or just a regular Zend_Gdata_App_Exception otherwise
/* try
{ */
$newEntry = $this->yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
$newEntry->setMajorProtocolVersion(2);
//if(isset($props['playlists']))
//$this->handlePlaylists($newEntry, explode(',', $props['playlists']));
return $newEntry->getVideoId();
/* }
catch (Zend_Gdata_App_HttpException $httpException)
{
// print_r($httpException);
echo $httpException->getRawResponseBody();
return null;
}
catch (Zend_Gdata_App_Exception $e)
{
// print_r($e);
echo $e->getMessage();
return null;
}*/
}
示例4: basename
$target_path = '/tmp/';
$target_path = $target_path . basename($_FILES['video_file']['name']);
if (!move_uploaded_file($_FILES['video_file']['tmp_name'], $target_path)) {
array_push($errors, 'Error uploading file!');
}
}
if (count($errors) == 0) {
$videoEntry = new Zend_Gdata_YouTube_VideoEntry();
$fs = $yt->newMediaFileSource($target_path);
$fs->setContentType($_FILES['video_file']['type']);
$fs->setSlug($_FILES['video_file']['name']);
$videoEntry->setMediaSource($fs);
$videoEntry->setVideoTitle($vtitle);
$videoEntry->setVideoDescription($description);
$videoEntry->setVideoCategory('Education');
$videoEntry->setVideoTags('isense');
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
$newEntry = null;
try {
$newEntry = $yt->insertEntry($videoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
array_push($errors, $httpException->getRawResponseBody());
} catch (Zend_Gdata_App_Exception $e) {
array_push($errors, $e->getMessage());
}
if (count($errors) == 0) {
$done = true;
$videoId = $newEntry->getVideoId();
$url = 'http://www.youtube.com/watch?v=' . $videoId;
createVideoItem($session->userid, $meta['experiment_id'], $vtitle, $description, $street, $citystate, $videoId, $url);
publishToTwitter('New Video Added To: "' . $meta['name'] . '" http://isense.cs.uml.edu/experiment.php?id=' . $meta['experiment_id']);
示例5: getAuthSubHttpClient
$videoTitle = null;
$videoDescription = null;
$videoCategory = null;
$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'];
示例6: uploadVideo
public function uploadVideo($Dailyop = false, $videoFile = false)
{
//if(!$Dailyop) throw new Exception("Invalid Dailyops ID");
//let's get the video that needs to be uploaded
$DailyopsShareParameter = ClassRegistry::init("DailyopsShareParameter");
$MediaFile = ClassRegistry::init("MediaFile");
//download the file to tmp
$tmpFile = $MediaFile->downloadVideoToTmp($videoFile['MediaFile']['id']);
//start the yt uploading processes
Zend_Loader::loadClass('Zend_Gdata_YouTube_VideoEntry');
$videoEntry = new Zend_Gdata_YouTube_VideoEntry();
$src = $this->youtube->newMediaFileSource($tmpFile);
$src->setContentType('video/mp4');
$src->setSlug($videoFile['MediaFile']['limelight_file']);
$videoEntry->setMediaSource($src);
//make the video title
$videoTitle = $Dailyop['Dailyop']['name'];
if (!empty($Dailyop['Dailyop']['sub_title'])) {
$videoTitle .= " - " . $Dailyop['Dailyop']['sub_title'];
}
$videoEntry->setVideoTitle($videoTitle);
//now make the video description
///////Make the links for the top of the posting
$videoDescription = "http://theberrics.com \n";
//////make the link to the post
$videoDescription .= "Original Post: http://theberrics.com/" . $Dailyop['DailyopSection']['uri'] . "/" . $Dailyop['Dailyop']['uri'] . "\n";
//////make a link to the section of the video
$videoDescription .= "More Like This: http://theberrics.com/" . $Dailyop['DailyopSection']['uri'] . "\n\n";
//////now stuff in the text description if any
if (!empty($Dailyop['Dailyop']['text_content'])) {
$videoDescription .= Sanitize::html($Dailyop['Dailyop']['text_content'], array("remove" => true));
}
$videoEntry->setVideoDescription($videoDescription);
//now lets set the tags for the post
$tags = Set::extract("/Tag/name", $Dailyop);
$tag_len = 0;
foreach ($tags as $k => $v) {
if (strlen($v) > 30) {
unset($tags[$k]);
} else {
$tag_len += strlen($v);
}
if ($tag_len >= 470) {
unset($tags[$k]);
}
}
$tags[] = "Skateboarding";
$tags[] = "The Berrics";
$tags = implode(",", $tags);
$videoEntry->setVideoTags($tags);
//set the category
$videoEntry->setVideoCategory('Sports');
//set some dev tags
$videoEntry->setVideoDeveloperTags(array("berricsapi", "berricsupload"));
//start the upload processes
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
try {
$newEntry = $this->youtube->insertEntry($videoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
$newEntry->setMajorProtocolVersion(2);
$videoid = $newEntry->getVideoId();
//get some additional info that we will need later
$params = serialize(array("editHref" => $newEntry->getEditLink()->getHref()));
//now create a share parameter entry for the post
$DailyopsShareParameter->create();
$DailyopsShareParameter->save(array("service" => "youtube", "dailyop_id" => $Dailyop['Dailyop']['id'], "foreign_key" => $videoid, "parameters" => $params));
return $DailyopsShareParameter->read();
}