PHP Youtube Data Api loading from another domain

I followed the google api examples to download on youtube. However, if I want to upload a file that is hosted in another domain, for example:

$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);

Any help would be greatly appreciated.

+3
source share
1 answer

The Zend API probably does not support this. However, if you have write permissions, you can upload the file to your server and then send it.

$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
0
source

Source: https://habr.com/ru/post/1796168/


All Articles