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


PHP Zend_Gdata_YouTube::newMediaGroup方法代码示例

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


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

示例1: 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";
    }
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:51,代码来源:service_youtube.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: 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);
     }
 }
开发者ID:ki8asui,项目名称:isography,代码行数:96,代码来源:fbmember.php

示例4: 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();
     }
 }
开发者ID:EntityFX,项目名称:QuikiJAR,代码行数:38,代码来源:Video.php

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


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