2011-08-19 11 views
5

मैं पीएचपी डाटा एपीआई का उपयोग कर YouTube पर वीडियो अपलोड करने के लिए कोशिश कर रहा हूँडाटा एपीआई का उपयोग कर यूट्यूब के लिए एक वीडियो अपलोड करने के बाद वीडियो URL प्राप्त करें - php

$yt = new Zend_Gdata_YouTube($httpClient); 
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); 

$filesource = $yt->newMediaFileSource('mytestmovie.mov'); 
$filesource->setContentType('video/quicktime'); 
$filesource->setSlug('mytestmovie.mov'); 

$myVideoEntry->setMediaSource($filesource); 

$myVideoEntry->setVideoTitle('My Test Movie'); 
$myVideoEntry->setVideoDescription('My Test Movie'); 
// Note that category must be a valid YouTube category ! 
$myVideoEntry->setVideoCategory('Comedy'); 

// Set keywords, note that this must be a comma separated string 
// and that each keyword cannot contain whitespace 
$myVideoEntry->SetVideoTags('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(); 
} 

किसी को भी कैसे का URL प्राप्त करने के लिए पता है $ newEntry ऑब्जेक्ट से अपलोड किया गया वीडियो।

किसी भी मदद की सराहना की होगी :)

+0

आप यहां अपना उत्तर मिल सकता है: http://groups.google.com/group/youtube-api-gdata/browse_thread/धागा/554bc26279925643। –

उत्तर

4

इस प्रयास करें:

try { 
      $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 
    'Zend_Gdata_YouTube_VideoEntry'); 
      $id = $newEntry->getVideoId(); // YOUR ANSWER IS HERE :) 
      echo $id; 
    } 
+0

:) धन्यवाद हाहा जो बहुत आसान था .. इसे एपीआई संदर्भ में नहीं मिला .. क्या आपको इसे ज़ेंड एपीआई रेफरी में मिला ?? – Abhishek

+0

मेरे पास एक ही समस्या थी और इस समस्या को हल करने के लिए इस कार्यवाही का पालन करने की आवश्यकता थी: https://groups.google.com/forum/?fromgroups=#!topic/youtube-api-gdata/fYbKwNP5Dj8 – Andrew

संबंधित मुद्दे