php - Uploading video from website backend to YouTube -


i doing site in cakephp users can upload videos , published on site once approved moderator. currently, accepting video files being uploaded on server. these files downloaded , checked moderator , if seem fine moderator click button upload video youtube , save link in database.

now, using clientlogin authenticate youtube , trying upload video using zend gdata libraries. there not documentation available on , not getting error back, not working:

require_once 'zend/loader.php'; zend_loader::loadclass('zend_gdata_youtube'); zend_loader::loadclass('zend_gdata_clientlogin'); zend_loader::loadclass('zend_gdata_app_exception'); zend_loader::loadclass('zend_gdata_app_authexception'); zend_loader::loadclass('zend_gdata_app_httpexception'); zend_loader::loadclass('zend_gdata_youtube_videoentry');  // define variables $email = 'myemail@gmail.com'; $passwd = 'pass'; $applicationid = 'company-app-1.0'; $developerkey = 'ai39si5ggdqnx588udunxgzl6i_uw32dr43fvh0ehf2jqn3cbik5pizhog1-ag_q8eavlwnixp7fls3uw5ofg45mzaxmw4xyafw';  // creating clientlogin authenticated http client try {     $client = zend_gdata_clientlogin::gethttpclient($email, $passwd, 'cl'); } catch (zend_gdata_app_captcharequiredexception $cre) {     echo 'url of captcha image: ' . $cre->getcaptchaurl() . "\n";     echo 'token id: ' . $cre->getcaptchatoken() . "\n"; } catch (zend_gdata_app_authexception $ae) {     echo 'problem authenticating: ' . $ae->exception() . "\n"; }  // passing developer key , clientid zend_gdata_youtube $yt = new zend_gdata_youtube($client, $applicationid, null, $developerkey);   // uploading video  $myvideoentry = new zend_gdata_youtube_videoentry(); $filesource = $yt->newmediafilesource('001.mov'); $filesource->setcontenttype('video/quicktime'); $filesource->setslug('001.mov'); $myvideoentry->setmediasource($filesource); $myvideoentry->setvideotitle('my test movie'); $myvideoentry->setvideodescription('my test movie');  // note category must valid youtube category ! $myvideoentry->setvideocategory('comedy');  // set keywords, note must comma separated string // , each keyword cannot contain whitespace $myvideoentry->setvideotags('baby, funny');  // optionally set developer tags /* $myvideoentry->setvideodevelopertags(array('mydevelopertag', 'anotherdevelopertag')); */  // set video private $myvideoentry->setvideoprivate();  // upload uri authenticated user  $uploadurl = 'http://uploads.gdata.youtube.com/feeds/app/default/uploads';   // try upload video, catching zend_gdata_app_httpexception // if availableor 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(); }  try {     $control = $videoentry->getcontrol(); } catch (zend_gdata_app_exception $e) {     echo $e->getmessage(); }  if ($control instanceof zend_gdata_app_extension_control) {     if ($control->getdraft() != null && $control->getdraft()->gettext() == 'yes') {         $state = $videoentry->getvideostate();         if ($state instanceof zend_gdata_youtube_extension_state) {             print 'upload status: ' . $state->getname() .' '. $state->gettext();         } else {             print 'not able retrieve video status information' .' yet. ' . "please try again shortly.\n";         }     } } 

apparently, giving me blank screen on localserver working fine on live server. had not changed default in uploadurl username.


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -