Search code examples
phpyoutubeyoutube-apigdatadropbox

Uploading video to YouTube using Dropbox public link?


I am using youtube ZEND gdata api to upload videos to My youtube account.But now I need to upload videos to YouTube which are stored in my DropBox account.I have public links or direct links for video files.Code I am using is:

<?php

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_App_Exception');

$developerKey = '******************';
$applicationId = '*********';
$clientId = '';

  $video_title = 'test movie';
  $video_description = 'test movie';
  $video_category = 'Entertainment';
  $video_tags = 'test,movie';
  $path_of_uploaded_file = 'http://dl.dropbox.com/uhh/336/test.wmv';



$authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
              $username = '*****',
              $password = '*****',
              $service = 'youtube',
              $client = null,
              $source = '*******', // a short string identifying your application
              $loginToken = null,
              $loginCaptcha = null,
              $authenticationURL);

$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);

$yt = new Zend_Gdata_YouTube($httpClient);

// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource($path_of_uploaded_file);

..
.
.
.
.
.?>

Error I am getting is:File to be uploaded at http://dl.dropbox.com/uhh/336/test.wmv does not exist or is not readable.

I don't why YouTube is throwing this error even though the URL is direct(Public) link. I am not getting what's wrong with my code and why it is not working.Please help :)


Solution

  • Just in case other are still looking for answers, I had a similar problem reading txt files with an app I wrote from Dropbox. I discovered that I wasn't using the right direct-link format. The correct link (for this threads example link) would be:

    dl.dropboxusercontent.com/uhh/336/test.wmv

    Just changing 'www' to 'dl' will work for web-browser as they handle redirects automatically. For apps and scripts you would have to integrate handling of redirects. Or just format the direct-link correctly.