2011-03-03 37 views
3

我遵循google api示例上傳到YouTube。但是,如果我想上傳另一個域託管例如文件:PHP Youtube數據Api從另一個域上傳

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); 

// create a new Zend_Gdata_App_MediaFileSource object 
$filesource = $yt->newMediaFileSource('http://www.myotherdomain.com/.../file.mov'); 
$filesource->setContentType('video/x-flv'); 

// set slug header 
$filesource->setSlug('http://www.myotherdomain.com/.../file.mov'); 

// add the filesource to the video entry 
$myVideoEntry->setMediaSource($filesource); 

任何幫助,將不勝感激

回答

0

在Zend API可能不支持這一點。但是,如果您擁有寫入權限,則可以將文件下載到服務器上,然後發送。

$curl = curl_init(); 
curl_setopt($curl, CURLOPT_HEADER, 0); 
curl_setopt($curl, CURLOPT_URL, 'http://www.myotherdomain.com/.../file.mov'); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
$contents = curl_exec($curl); 
curl_close($curl); 

$file = fopen('temp/file.mov', 'w'); // If file is not found, attempts to create it 
fwrite($file, $contents); 
fclose($file); 

// Upload via YouTube