Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 1.44 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Form Creation for Youtube API Direct Upload
  2. $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
  3.  
  4. $myVideoEntry->setVideoTitle('My Test Movie');
  5. $myVideoEntry->setVideoDescription('My Test Movie');
  6. $myVideoEntry->setVideoCategory('Autos');
  7. $myVideoEntry->setVideoPrivate();
  8. $myVideoEntry->SetVideoTags('cars, funny');
  9.  
  10. $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
  11. $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
  12. $tokenValue = $tokenArray['token'];
  13. $postUrl = $tokenArray['url'];
  14.  
  15. // place to redirect user after upload
  16. $nextUrl = 'http://example.com/formprocess.php';
  17.  
  18. // build the form
  19. $form = '<form id="youtube_upload" action="'. $postUrl .'?nexturl='. $nextUrl .
  20.         '" method="post" enctype="multipart/form-data" target="uploader">'.
  21.         '<input id="video_title" name="video_title" type="text"/>'.
  22.         '<input id="file_upload" name="file_upload" type="file"/>'.
  23.         '<input name="token" type="hidden" value="'. $tokenValue .'"/>'.
  24.         '<input value="Upload Video File" type="submit" />'.
  25.         '</form><iframe id="uploader" name="uploader" style="display: none; width: 500px; height: 200px; border:1px solid #000;"></iframe>
  26. ';
  27.  
  28. echo $form;
  29.        
  30. $myVideoEntry->setMediaSource($filesource);
  31. $myVideoEntry->setVideoTitle($ytTitle); // Set the title
  32. $myVideoEntry->setVideoDescription($ytDesc); // Set the description
  33. $myVideoEntry->setVideoCategory($ytCat);
  34. $myVideoEntry->SetVideoTags($ytTags);