本文整理汇总了PHP中Zend_Gdata_YouTube::insertEntry方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube::insertEntry方法的具体用法?PHP Zend_Gdata_YouTube::insertEntry怎么用?PHP Zend_Gdata_YouTube::insertEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_YouTube
的用法示例。
在下文中一共展示了Zend_Gdata_YouTube::insertEntry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
*
* @param record_adapter $record
* @param array $options
* @return string The new distant Id
*/
public function upload(record_adapter $record, array $options = [])
{
switch ($record->get_type()) {
case 'video':
$video_entry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = new Zend_Gdata_App_MediaFileSource($record->get_hd_file()->getRealPath());
$filesource->setContentType($record->get_hd_file()->get_mime());
$filesource->setSlug($record->get_title());
$video_entry->setMediaSource($filesource);
$video_entry->setVideoTitle($options['title']);
$video_entry->setVideoDescription($options['description']);
$video_entry->setVideoCategory($options['category']);
$video_entry->SetVideoTags(explode(' ', $options['tags']));
$video_entry->setVideoDeveloperTags(['phraseanet']);
if ($options['privacy'] == "public") {
$video_entry->setVideoPublic();
} else {
$video_entry->setVideoPrivate();
}
$app_entry = $this->_api->insertEntry($video_entry, self::UPLOAD_URL, 'Zend_Gdata_YouTube_VideoEntry');
/*
* set major protocole version to 2 otherwise you get exception when calling getVideoId
* but setting setMajorProtocolVersion to 2 at the new entry introduce a new bug with getVideoState
* @see http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/7d86cac0d3f90e3f/d9291d7314f99be7?pli=1
*/
$app_entry->setMajorProtocolVersion(2);
return $app_entry->getVideoId();
break;
default:
throw new Bridge_Exception_InvalidRecordType('Unknown format');
break;
}
}
示例2: youtubeUpload
/**
* Uploads video to youtube
*/
function youtubeUpload($username, $password, $devkey, $filename, $filetype, $movie_title, $movie_desc, $keywords, $category_name, $coords = '')
{
require_once 'Zend/Loader.php';
// the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service = 'youtube', $client = null, $source = 'core_dev', $loginToken = null, $loginCaptcha = null, $authenticationURL);
$httpClient->setHeaders('X-GData-Key', "key={$devkey}");
$yt = new Zend_Gdata_YouTube($httpClient);
// create a new Zend_Gdata_YouTube_VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource($filename);
$filesource->setContentType($filetype);
// set slug header
$filesource->setSlug($filename);
//FIXME: vafan är en slug header???
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
// create a new Zend_Gdata_YouTube_Extension_MediaGroup object
$mediaGroup = $yt->newMediaGroup();
$mediaGroup->title = $yt->newMediaTitle()->setText($movie_title);
$mediaGroup->description = $yt->newMediaDescription()->setText($movie_desc);
// the category must be a valid YouTube category
// optionally set some developer tags (see Searching by Developer Tags for more details)
$mediaGroup->category = array($yt->newMediaCategory()->setText($category_name)->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'));
// set keywords, please note that they cannot contain white-space
$mediaGroup->keywords = $yt->newMediaKeywords()->setText($keywords);
$myVideoEntry->mediaGroup = $mediaGroup;
if ($coords) {
// set video location
$yt->registerPackage('Zend_Gdata_Geo');
$yt->registerPackage('Zend_Gdata_Geo_Extension');
$where = $yt->newGeoRssWhere();
$position = $yt->newGmlPos($coords);
$where->point = $yt->newGmlPoint($position);
$myVideoEntry->setWhere($where);
}
// upload URL for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage() . "\n";
}
}
示例3: upload
public static function upload($asset)
{
try {
$credentials = Asset_Video_Youtube::getYoutubeCredentials();
if (!$credentials) {
return;
}
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $credentials["username"], $password = $credentials["password"], $service = 'youtube', $client = Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"), $source = 'Pimcore', $loginToken = null, $loginCaptcha = null, 'https://www.google.com/youtube/accounts/ClientLogin');
$httpClient->setConfig(array("timeout" => 3600));
$apikey = $credentials["apiKey"];
$httpClient->setHeaders('X-GData-Key', "key={$apikey}");
$yt = new Zend_Gdata_YouTube($httpClient);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource($asset->getFileSystemPath());
$filesource->setContentType($asset->getMimetype());
$filesource->setSlug($asset->getFilename());
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($asset->getFullPath());
$myVideoEntry->setVideoDescription($asset->getFullPath());
$myVideoEntry->setVideoCategory('Comedy');
// Set keywords, note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->SetVideoTags('---, ---');
// Optionally set some developer tags
$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag', 'anotherdevelopertag'));
// Upload URI for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
$asset->setCustomSetting("youtube", array("id" => strval($newEntry->getVideoId())));
$asset->save();
return true;
} catch (Exception $e) {
$asset->setCustomSetting("youtube", array("failed" => true));
$asset->save();
}
} catch (Exception $e) {
Logger::error($e);
}
return false;
}
示例4: doYoutubeUpload
public function doYoutubeUpload($options = array('title' => '', 'titleAlias' => '', 'introText' => '', 'source' => '', 'tags' => '', 'description' => ''))
{
$this->fileVideoName = $this->upload->getUploadName();
$title = $options['title'];
$titleAlias = $options['titleAlias'];
$introText = $options['introText'];
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
$fileName = $this->fileVideoName;
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$httpclient = Zend_Gdata_ClientLogin::getHttpClient($this->username, $this->password, $service = 'youtube', $client = null, $source = $options['source'], $loginToken = null, $loginCaptcha = null, $this->authenticationURL);
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube($httpclient, $options['name'], $options['name'], $this->developerKey);
$videoEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource($fileName);
$filesource->setContentType('video/' . $this->upload->fileExt);
$filesource->setSlug($fileName);
$videoEntry->setMediaSource($filesource);
$videoEntry->setVideoTitle($title);
$videoEntry->setVideoDescription($options['description']);
$videoEntry->setVideoCategory($options['category']);
$videoEntry->SetVideoTags($options['tags']);
try {
$videoEntry = $yt->insertEntry($videoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
$state = $videoEntry->getVideoState();
if ($state) {
$youtubeId = $videoEntry->getVideoId();
$this->videoId = $youtubeId;
$this->videoUrl = "http://youtu.be/{$youtubeId}";
$this->thumbSrc = "http://img.youtube.com/vi/{$youtubeId}/default.jpg";
$this->duration = $this->length = 0;
$this->parseAdditionalMetadata();
} else {
throw new Exception("Not able to retrieve the video status information yet. " . "Please try again later.\n");
}
} catch (Zend_Gdata_App_HttpException $httpException) {
throw new Exception($httpException->getRawResponseBody());
} catch (Zend_Gdata_App_Exception $e) {
throw new Exception($e->getMessage());
}
}
示例5: testAddAndDeleteSubscriptionToQueryV2
public function testAddAndDeleteSubscriptionToQueryV2()
{
$developerKey = constant('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY');
$clientId = constant('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID');
$service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME;
$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $this->user, $password = $this->pass, $service = $service, $client = null, $source = 'Google-UnitTests-1.0', $loginToken = null, $loginCaptcha = null, $authenticationURL);
$yt = new Zend_Gdata_YouTube($httpClient, 'Google-UnitTests-1.0', $clientId, $developerKey);
$yt->setMajorProtocolVersion(2);
$queryStringToSubscribeTo = 'zend';
// Test for deletion first in case something went wrong
// last time the test was run (network, etc...)
$subscriptionFeed = $yt->getSubscriptionFeed($this->ytAccount);
$successDeletionUpFront = true;
$message = null;
foreach ($subscriptionFeed as $subscriptionEntry) {
$subscriptionType = null;
$categories = $subscriptionEntry->getCategory();
// examine the correct category element since there are multiple
foreach ($categories as $category) {
if ($category->getScheme() == 'http://gdata.youtube.com/schemas/2007/' . 'subscriptiontypes.cat') {
$subscriptionType = $category->getTerm();
}
}
if ($subscriptionType == 'query') {
if ($subscriptionEntry->getQueryString() == $queryStringToSubscribeTo) {
try {
$subscriptionEntry->delete();
} catch (Zend_App_Exception $e) {
$message = $e->getMessage();
$successDeletionUpFront = false;
}
}
}
}
$this->assertTrue($successDeletionUpFront, 'Found existing ' . 'subscription in unit test, could not delete prior to running ' . 'test -- ' . $message);
// Query
$newSubscription = $yt->newSubscriptionEntry();
$newSubscription->category = array($yt->newCategory('query', $this->subscriptionTypeSchema));
$newSubscription->setQueryString($yt->newQueryString($queryStringToSubscribeTo));
$postUrl = 'http://gdata.youtube.com/feeds/api/users/default/subscriptions';
$successPosting = true;
$message = null;
$insertedSubscription = null;
try {
$insertedSubscription = $yt->insertEntry($newSubscription, $postUrl, 'Zend_Gdata_YouTube_SubscriptionEntry');
} catch (Zend_App_Exception $e) {
$message = $e->getMessage();
$successPosting = false;
}
$this->assertTrue($successPosting, $message);
// Delete it
$successDeletion = true;
$message = null;
try {
$insertedSubscription->delete();
} catch (Zend_App_Exception $e) {
$message = $e->getMessage();
$successDeletion = false;
}
$this->assertTrue($successDeletion, $message);
}
示例6: createPlaylist
/**
* Create a new playlist for the currently authenticated user
*
* @param string $playlistTitle Title of the new playlist
* @param string $playlistDescription Description for the new playlist
* @return void
*/
function createPlaylist($playlistTitle, $playlistDescription)
{
$httpClient = getAuthSubHttpClient();
$youTubeService = new Zend_Gdata_YouTube($httpClient);
$feed = $youTubeService->getPlaylistListFeed('default');
if (loggingEnabled()) {
logMessage($httpClient->getLastRequest(), 'request');
logMessage($httpClient->getLastResponse()->getBody(), 'response');
}
$newPlaylist = $youTubeService->newPlaylistListEntry();
$newPlaylist->description = $youTubeService->newDescription()->setText($playlistDescription);
$newPlaylist->title = $youTubeService->newTitle()->setText($playlistDescription);
if (!$feed instanceof Zend_Gdata_YouTube_PlaylistListFeed) {
print 'ERROR - Could not retrieve playlists<br />' . printCacheWarning();
return;
}
$playlistFeedUrl = 'http://gdata.youtube.com/feeds/users/default/playlists';
try {
$updatedEntry = $youTubeService->insertEntry($newPlaylist, $playlistFeedUrl);
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 create new playlist: ' . $e->getMessage();
return;
}
print 'Playlist added succesfully.<br /><a href="#" onclick="' . 'ytVideoApp.retrievePlaylists();"' . '">(refresh your playlist listing)</a><br />' . printCacheWarning();
}
示例7: uploadvideo
function uploadvideo()
{
if (!empty($_FILES['image'])) {
$uploaddir = BASEPATH . '../video';
$fname = $_FILES['image']['name'];
$fsize = $_FILES['image']['size'];
$ftmpname = $_FILES['image']['tmp_name'];
$ext = '';
if (preg_match("/.+(\\..+)\$/", $fname, $matches)) {
$ext = strtolower($matches[1]);
}
//file extension
$filename = $this->_genFileName($ext, $uploaddir);
$uploadfile = $uploaddir . '/' . $filename;
//debug: //echo $uploadfile;
//$fsize < 3000000 //allow to upload only pics that less then file_upload_size bytes
if (in_array($ext, array('.avi', '.3gp', '.mov', '.mp4', '.mpeg', '.flv', '.swf', '.mkv'))) {
if (move_uploaded_file($ftmpname, $uploadfile)) {
//uploaded
$uploaded = TRUE;
} else {
//Error while uploading file
}
} else {
//Picture shouldn't exceed file_upload_size bytes
$_data['msg'] = $msg = 'Uploaded file should be a video';
}
} else {
$_data['msg'] = $msg = 'You should select a video to upload';
}
if (empty($uploaded)) {
if (empty($msg)) {
$_data['msg'] = $msg = 'Cannot upload file';
}
$this->load->view('member_post_video', $_data);
} else {
$yt = new Zend_Gdata_YouTube($this->client);
// create a new Zend_Gdata_YouTube_VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource($uploadfile);
$filesource->setContentType('video/quicktime');
// set slug header
$filesource->setSlug($uploadfile);
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
// create a new Zend_Gdata_YouTube_MediaGroup object
$mediaGroup = $yt->newMediaGroup();
$mediaGroup->title = $yt->newMediaTitle()->setText('My Movie');
$mediaGroup->description = $yt->newMediaDescription()->setText('My Movie Description');
// the category must be a valid YouTube category
// optionally set some developer tags (see Searching by Developer Tags for more details)
$mediaGroup->category = array($yt->newMediaCategory()->setText('Autos')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'));
// set keywords
$mediaGroup->keywords = $yt->newMediaKeywords()->setText('test');
$myVideoEntry->mediaGroup = $mediaGroup;
// set video location
//$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);
//$entry->setWhere($where);
// upload URL for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
//print"<pre>";var_dump($newEntry->getVideoWatchPageUrl());print"</pre>";
if (!empty($this->fbUserId) && !empty($this->userSettings) && $this->userSettings[0]['facebook_vids_y_n'] == 1) {
// uploading video to Facebook
try {
$this->facebook->api_client->video_upload($uploadfile, "Uploading video with " . $this->conf['site_name'], null);
} catch (Exception $ex) {
echo $ex->getMessage();
//echo "Cannot upload video to facebook";
}
}
$lastMessage = $this->Post_model->getWhere(null, $limit = 1, $offset = 0, $order = 'id DESC');
if (!empty($lastMessage) && $lastMessage[0]['user_id'] == $this->getUserId() && $lastMessage[0]['site_id'] == $this->subdomainId && $lastMessage[0]['post_type'] == 'video') {
$this->Post_videos_model->insert($lastMessage[0]['id'], $newEntry->getVideoWatchPageUrl());
} else {
$this->Post_model->insert($this->getUserId(), $this->subdomainId, date("Y-m-d H:i"), 'video', NULL, $newEntry->getVideoWatchPageUrl(), NULL);
}
$this->load->view('member_post_video_success');
$sitedata = $this->Site_model->getById($this->subdomainId);
$users = $this->User_is_member_of_site_model->getList(0, 0, array('subscribe_y_n' => 1, 'site_id' => $this->subdomainId), '', array('table' => 'users', 'field1' => 'id', 'field2' => 'user_id'));
foreach ($users as $user) {
$this->_sendemail('newpost', array('sitename' => $sitedata['name'], 'subdomain' => $sitedata['subdomain'], 'email' => $user['email']));
}
//$this->load->view('member_post_video_success', $_data);
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
@unlink($uploadfile);
}
}
示例8: mediaboard_cron
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
*
* @uses $CFG
* @return boolean
* @todo Finish documenting this function
**/
function mediaboard_cron()
{
global $CFG, $DB;
$fs = get_file_storage();
if ($data = $DB->get_record_sql("SELECT * FROM {mediaboard_process} WHERE `status`='open' LIMIT 1")) {
$CFG->mediaboard_convert = 0;
if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
$CFG->mediaboard_convert = $CFG->mediaboard_video_convert;
} else {
if (in_array($data->type, json_decode(MEDIABOARD_AUDIOTYPES))) {
$CFG->mediaboard_convert = $CFG->mediaboard_audio_convert;
}
}
//Check converting method local or mserver
if ($CFG->mediaboard_convert == 1) {
if (strstr($CFG->mediaboard_convert_url, "ffmpeg")) {
$CFG->mediaboard_convert = 2;
}
}
//local
if ($CFG->mediaboard_convert == 1) {
$from = mediaboard_getfileid($data->itemid);
$add = new stdClass();
$add->id = $data->id;
$add->status = 'send';
$DB->update_record("mediaboard_process", $add);
$ch = curl_init();
if (in_array($data->type, json_decode(MEDIABOARD_AUDIOTYPES))) {
$datasend = array('name' => $data->name, 'mconverter_wav' => '@' . $from->fullpatch);
}
if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
$datasend = array('name' => $data->name, 'mconverter_m4a' => '@' . $from->fullpatch);
}
curl_setopt($ch, CURLOPT_URL, $CFG->mediaboard_convert_url . '/send.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datasend);
curl_exec($ch);
} else {
if ($CFG->mediaboard_convert == 3) {
$from = mediaboard_getfileid($data->itemid);
$add = new stdClass();
$add->id = $data->id;
$add->status = 'send';
$DB->update_record("mediaboard_process", $add);
if (in_array($data->type, json_decode(MEDIABOARD_VIDEOTYPES))) {
if ($item = $DB->get_record("mediaboard_files", array("itemoldid" => $data->itemid))) {
$table = 'mediaboard_files';
} else {
if ($item = $DB->get_record("mediaboard_comments", array("itemoldid" => $data->itemid))) {
$table = 'mediaboard_comments';
}
}
@set_include_path($CFG->dirroot . '/mod/mediaboard/library');
require_once "Zend/Gdata/ClientLogin.php";
require_once "Zend/Gdata/HttpClient.php";
require_once "Zend/Gdata/YouTube.php";
require_once "Zend/Gdata/App/HttpException.php";
require_once 'Zend/Uri/Http.php';
$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $CFG->mediaboard_youtube_email, $password = $CFG->mediaboard_youtube_password, $service = 'youtube', $client = null, $source = 'mediaboard', $loginToken = null, $loginCaptcha = null, $authenticationURL);
$yt = new Zend_Gdata_YouTube($httpClient, 'mediaboard', NULL, $CFG->mediaboard_youtube_apikey);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
/// unlisted upload
$accessControlElement = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
$accessControlElement->extensionAttributes = array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied'));
$myVideoEntry->extensionElements = array($accessControlElement);
$filesource = $yt->newMediaFileSource($from->fullpatch);
$filesource->setContentType($data->type);
$filesource->setSlug('slug');
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($from->author);
$myVideoEntry->setVideoDescription($from->author);
$myVideoEntry->setVideoCategory('Education');
$myVideoEntry->SetVideoTags('mediaboard');
//$myVideoEntry->setVideoDeveloperTags(array($item->id));
//$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);
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
$DB->delete_records('mediaboard_process', array('id' => $data->id));
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
$DB->delete_records('mediaboard_process', array('id' => $data->id));
}
//.........这里部分代码省略.........
示例9: uploadOnYT
public function uploadOnYT()
{
$httpClient = $this->authYT($username, $password);
$yt = new Zend_Gdata_YouTube($httpClient);
// create a new Zend_Gdata_YouTube_VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource('mytestmovie.mov');
$filesource->setContentType('video/quicktime');
// set slug header
$filesource->setSlug('mytestmovie.mov');
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
// create a new Zend_Gdata_YouTube_MediaGroup object
$mediaGroup = $yt->newMediaGroup();
$mediaGroup->title = $yt->newMediaTitle()->setText('My Test Movie');
$mediaGroup->description = $yt->newMediaDescription()->setText('My description');
// the category must be a valid YouTube category
// optionally set some developer tags (see Searching by Developer Tags for more details)
$mediaGroup->category = array($yt->newMediaCategory()->setText('Autos')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'), $yt->newMediaCategory()->setText('mydevelopertag')->setScheme('http://gdata.youtube.com/schemas/2007/developertags.cat'), $yt->newMediaCategory()->setText('anotherdevelopertag')->setScheme('http://gdata.youtube.com/schemas/2007/developertags.cat'));
// set keywords
$mediaGroup->keywords = $service->newMediaKeywords()->setText('cars, funny');
$myVideoEntry->mediaGroup = $mediaGroup;
// set video location
$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);
$entry->setWhere($where);
// upload URL for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
}
示例10: catch
}
}
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']);
}
}
}
$smarty->assign('meta', $meta);
示例11: array
/**
* Sube un archivo
* @param boolean $ie6 es Internet Explorer 6
* @return array
*/
function _upload($ie = NULL)
{
$this->load->library('zend');
$this->zend->load('Zend/Gdata/YouTube');
$this->zend->load('Zend/Gdata/ClientLogin');
$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = 'alvaropereyra.storage1@gmail.com', $password = 'vossosalvarox', $service = 'youtube', $client = null, $source = 'LaMulaSRD', $loginToken = null, $loginCaptcha = null, $authenticationURL);
$clientId = "ytapi-AlvaroPereyraRab-WebPublishing-afg0bc0f-0";
$developerKey = "AI39si77SKdfoJ3spb7HZHe_tUVcOKX_TAn7Fne7BU8ux6ixJ6E8ZdNmZ7UeJs7y3ZGOfVyNAzSe4nYJqIX3Lu7RNryf-dOn9A";
$httpClient->setHeaders('X-GData-Key', "key={$developerKey}");
$applicationId = "SRD-LaMula-1.0";
$yt = new Zend_Gdata_YouTube($httpClient);
$filesource = $yt->newMediaFileSource($_FILES["Filedata"]['tmp_name']);
$filesource->setContentType('video/quicktime');
// set slug header
$filesource->setSlug($_FILES["Filedata"]['tmp_name']);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
// create a new Zend_Gdata_YouTube_MediaGroup object
$mediaGroup = $yt->newMediaGroup();
$mediaGroup->title = $yt->newMediaTitle()->setText('LaMula');
$mediaGroup->description = $yt->newMediaDescription()->setText('Subido desde LaMula');
$mediaGroup->keywords = $yt->newMediaKeywords()->setText('lamula');
// the category must be a valid YouTube category
// optionally set some developer tags (see Searching by Developer Tags for more details)
$mediaGroup->category = array($yt->newMediaCategory()->setText('Entertainment')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'));
// set keywords
// $mediaGroup->keywords = $service->newMediaKeywords()->setText('cars, funny');
$myVideoEntry->mediaGroup = $mediaGroup;
// upload URL for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
//returns the video URL and the thumbnail URB
getVideoThumbnails();
if ($this->_is_ie6() == TRUE or $ie != NULL) {
//return htmlspecialchars($this->findFlashUrl($newEntry));
return htmlspecialchars($newEntry->getVideoWatchPageUrl());
} else {
echo htmlspecialchars($newEntry->getVideoWatchPageUrl());
}
} catch (Zend_Gdata_App_Exception $e) {
return $e->getMessage();
}
}
示例12: comment
function comment($entry, $comment)
{
$username = $_SESSION['username'];
$query = "select token from user where username='{$username}'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$token = $row['token'];
$httpClient = Zend_Gdata_AuthSub::getHttpClient($token);
$developerKey = 'AI39si5uCFW5FETweIaPnbNJUP88YvpOtSoy7FSUnYnTFVH4liFKzqWTkndATtgiltByN54tPcVjsScyh3S28P-D4PC4n73alg';
$applicationId = 'EazySubs';
$clientId = 'EazySubs';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
try {
$videoEntry = $yt->getVideoEntry($entry);
$newComment = $yt->newCommentEntry();
$newComment->content = $yt->newContent()->setText($comment);
// post the comment to the comments feed URL for the video
$commentFeedPostUrl = $videoEntry->getVideoCommentFeedUrl();
$updatedVideoEntry = $yt->insertEntry($newComment, $commentFeedPostUrl, 'Zend_Gdata_YouTube_CommentEntry');
return true;
} catch (Exception $e) {
return false;
}
}
示例13: array
$matches = array();
$result = mysql_query("SELECT * FROM matchids WHERE " . $crawl_string . " or sessionid = 680462533 LIMIT 0, 10");
while ($row = mysql_fetch_array($result)) {
if ($row['sessionid'] > 1000000) {
$matches["match_" . strtolower(dechex($row['sessionid']))] = $row;
}
}
echo 'Crawling ' . count($matches) . ' match(es)<br/>';
$matchlist = implode(' | ', array_keys($matches));
if (empty($matchlist)) {
die;
}
echo $matchlist . "<br/>";
$query = $yt->newVideoQuery();
$query->setVideoQuery($matchlist);
$query->setMaxResults(50);
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
foreach ($videoFeed as $videoEntry) {
preg_match_all("/(Scout|Soldier|Pyro|Demoman|Heavy|Engineer|Medic|Sniper|Spy)|match_([0-9a-f]{6,})/", implode("|", $videoEntry->getVideoTags()), $matchid);
$authobj = $videoEntry->getAuthor();
$matchinfo = $matches[$matchid[0][1]];
if (mysql_num_rows(mysql_query("SELECT youtubeid FROM videos WHERE youtubeid = '" . $videoEntry->getVideoId() . "'")) != 0) {
mysql_query("UPDATE videos SET title = '" . mysql_real_escape_string($videoEntry->getVideoTitle()) . "', description = '" . mysql_real_escape_string($videoEntry->getVideoDescription()) . "' WHERE youtubeid = '" . $videoEntry->getVideoId() . "'");
echo mysql_error();
} else {
$nextmatch = mysql_fetch_array(mysql_query("SELECT * FROM matchids WHERE matchdate > '" . $matchinfo['matchdate'] . "' AND serverid = " . $matchinfo['serverid'] . " LIMIT 1"));
mysql_query("INSERT INTO videos ( youtubeid, youtubeuser, map, sessionid, matchdate, matchduration, role, serverid, duration, title, description ) VALUES ( '" . $videoEntry->getVideoId() . "', '" . $authobj[0]->getName() . "', '" . $matchinfo['mapname'] . "', '" . $matchinfo['sessionid'] . "', '" . $matchinfo['matchdate'] . "', '" . (strtotime($nextmatch['matchdate']) - strtotime($matchinfo['matchdate'])) . "', '" . $matchid[0][0] . "', '" . $matchinfo['serverid'] . "', '" . $videoEntry->getVideoDuration() . "', '" . mysql_real_escape_string($videoEntry->getVideoTitle()) . "', '" . mysql_real_escape_string($videoEntry->getVideoDescription()) . "' )");
echo mysql_error();
$yt->insertEntry($videoEntry, $yt->getUserFavorites("LethalZone")->getSelfLink()->href);
}
}
示例14: catch
function for_youtube($file_convert_for_youtube, $id_row)
{
$db = Zend_Db_Table::getDefaultAdapter();
$films_info = $db->fetchRow("SELECT f.id, f.name, m.id as menu_activ, f.for_youtube, f.text, f.year\n\t\t\t, ( SELECT GROUP_CONCAT( s.name ORDER BY fj.id SEPARATOR ', ') FROM film_janr fj join spravochnik s on s.id = fj.id_janr WHERE fj.films_id = f.id) as janr\n\t\t\t\t\t\tFROM menu m\n\t\t\t\t\t\tjoin films f on f.page_id = m.id\n\t\t\t\t\t\tWHERE m.type = 'films' and f.id = " . $id_row);
$films_info['translit_url'] = $this->translitUrlName($films_info['name']);
if ($films_info['for_youtube'] == 1) {
$authenticationURL = 'https://www.google.com/accounts/ClientLogin';
try {
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = 'treetv9@gmail.com', $password = 'asd123321', $service = 'youtube', $client = null, $source = 'MySource', $loginToken = null, $loginCaptcha = null, $authenticationURL);
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
} catch (Zend_Gdata_App_AuthException $ae) {
echo 'Problem authenticating: ' . $ae->exception() . "\n";
}
$applicationId = "causal-rite-634";
$clientId = "748030821368-ddkt4brpcq7623jii6l2bhc6ujfi08e9.apps.googleusercontent.com";
//"11588627092-akui7d8un28eerombrt8784j4fpn1p12.apps.googleusercontent.com";
$developerKey = "AI39si7LpRb8zR-_eP9tR-TPRAuBTBdM1gBHFssCCnc1sGCyJozLbYYPmlHW7lBSYxBYC4VKYmOp1mXMKQveeyXgOjsLNF0oQA";
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource($file_convert_for_youtube);
$filesource->setContentType('video/quicktime');
$filesource->setSlug($file_convert_for_youtube);
$myVideoEntry->setMediaSource($filesource);
///названиефильма/ - Русский трейлер /год
$name_trayler = $films_info['name'] . ' - Русский трейлер ' . $films_info['year'];
if (mb_strlen($name_trayler) >= 60) {
$temp_name_trayler = mb_substr($name_trayler, 0, 60, 'utf-8');
$name_trayler = mb_substr($temp_name_trayler, 0, mb_strrpos($temp_name_trayler, ' '), 'utf-8');
}
$myVideoEntry->setVideoTitle($name_trayler);
$myVideoEntry->setVideoDescription('Смотреть онлайн или скачать полную версию: http://tree.tv/film/' . $id_row . '-' . $films_info['translit_url'] . '
' . $films_info['text']);
// Note that category must be a valid YouTube category !
$myVideoEntry->setVideoCategory('Film');
// Set keywords, note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->SetVideoTags('русский трейлер, смотреть, русский, онлайн, ' . date("Y") . ', фильм, кино, бесплатно, трейлер, trailer, тизер,' . $films_info['janr']);
//('cars, funny');
// Optionally set some developer tags
$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag', 'anotherdevelopertag'));
// Optionally set the video's location
$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/users/default/uploads';
// Try to upload the video, catching a Zend_Gdata_App_HttpException
// if availableor just a regular Zend_Gdata_App_Exception
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
$db->query("update films SET for_youtube = '0' \n\t\t\t\t\t\t\tWHERE id = " . $id_row);
}
}
示例15: videoboard_cron
function videoboard_cron()
{
global $DB, $CFG;
if ($data = $DB->get_record_sql("SELECT * FROM {videoboard_process} WHERE `status`='open' LIMIT 1")) {
$CFG->videoboard_convert = 0;
if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
$CFG->videoboard_convert = $CFG->videoboard_video_convert;
} else {
if (in_array($data->type, json_decode(VIDEOBOARD_AUDIOTYPES))) {
$CFG->videoboard_convert = $CFG->videoboard_audio_convert;
}
}
//Check converting method local or mserver
if ($CFG->videoboard_convert == 1) {
if (strstr($CFG->videoboard_convert_url, "ffmpeg")) {
$CFG->videoboard_convert = 2;
}
}
//local
if ($CFG->videoboard_convert == 1) {
$from = videoboard_getfileid($data->itemid);
$add = new stdClass();
$add->id = $data->id;
$add->status = 'send';
$DB->update_record("videoboard_process", $add);
$ch = curl_init();
if (in_array($data->type, json_decode(VIDEOBOARD_AUDIOTYPES))) {
$datasend = array('name' => $data->name, 'mconverter_wav' => '@' . $from->fullpatch);
}
if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
$datasend = array('name' => $data->name, 'mconverter_m4a' => '@' . $from->fullpatch);
}
curl_setopt($ch, CURLOPT_URL, $CFG->videoboard_convert_url . '/send.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datasend);
curl_exec($ch);
} else {
if ($CFG->videoboard_convert == 3) {
$from = videoboard_getfileid($data->itemid);
$add = new stdClass();
$add->id = $data->id;
$add->status = 'send';
$DB->update_record("videoboard_process", $add);
if (in_array($data->type, json_decode(VIDEOBOARD_VIDEOTYPES))) {
if ($item = $DB->get_record("videoboard_files", array("itemoldid" => $data->itemid))) {
$table = 'videoboard_files';
} else {
if ($item = $DB->get_record("videoboard_comments", array("itemoldid" => $data->itemid))) {
$table = 'videoboard_comments';
}
}
@set_include_path($CFG->dirroot . '/mod/videoboard/library');
require_once "Zend/Gdata/ClientLogin.php";
require_once "Zend/Gdata/HttpClient.php";
require_once "Zend/Gdata/YouTube.php";
require_once "Zend/Gdata/App/HttpException.php";
require_once 'Zend/Uri/Http.php';
$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $CFG->videoboard_youtube_email, $password = $CFG->videoboard_youtube_password, $service = 'youtube', $client = null, $source = 'VideoBoard', $loginToken = null, $loginCaptcha = null, $authenticationURL);
$yt = new Zend_Gdata_YouTube($httpClient, 'VideoBoard', NULL, $CFG->videoboard_youtube_apikey);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
/// unlisted upload
$accessControlElement = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
$accessControlElement->extensionAttributes = array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied'));
$myVideoEntry->extensionElements = array($accessControlElement);
$filesource = $yt->newMediaFileSource($from->fullpatch);
$filesource->setContentType($data->type);
$filesource->setSlug('slug');
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($from->author);
$myVideoEntry->setVideoDescription($from->author);
$myVideoEntry->setVideoCategory('Education');
$myVideoEntry->SetVideoTags('videoboard');
//$myVideoEntry->setVideoDeveloperTags(array($item->id));
//$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);
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
$DB->delete_records('videoboard_process', array('id' => $data->id));
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
$DB->delete_records('videoboard_process', array('id' => $data->id));
}
$itemidyoutube = $newEntry->getVideoId();
if (!empty($itemidyoutube)) {
$DB->set_field($table, "itemyoutube", $itemidyoutube, array("id" => $item->id));
}
$DB->delete_records('videoboard_process', array('id' => $data->id));
} else {
$DB->delete_records('videoboard_process', array('id' => $data->id));
}
} else {
if ($CFG->videoboard_convert == 2) {
//.........这里部分代码省略.........