Search code examples
phpzend-frameworkyoutube-apizend-gdata

Get response from loading movie to youtube


i am using the ZEND Gdata and youtube api to upload vidoes to youtube http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Direct_Upload

When I upload a Video how do I capture the Video ID that was generated and also the youtube link ?

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();
}

thank you very much


Solution

  • This line:

    $newEntry = $yt->insertEntry($myVideoEntry,$uploadUrl,'Zend_Gdata_YouTube_VideoEntry');
    

    returns a Zend_Gdata_YouTube_VideoEntry object.

    The Zend Framework API docs for Zend_Gdata_YouTube_VideoEntry lists all the methods and properties that class makes available. There is similar documentation for all Zend Framework classes, and it's automatically generated, so it's often a good place to go if the manual doesn't answer a question.

    From looking there, I'd say that you'd call:

    • $newEntry->getVideoId() to get the video ID
    • $newEntry->getVideoWatchPageUrl() to get the video URL