Hello, I am currently working on a php browser upload project that
errors out on me every time. I seem to be updating the token so I
don't see where the issue is.
My Code:
session_start();
require_once $_SERVER["DOCUMENT_ROOT"].'/podlab/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$dkey = 'My-Dev-Key';
include 'youtube_functions.php';
youtube_start();
//Request First Token from Youtube
getAuthSubRequestUrl();
echo '<a href="'.getAuthSubRequestUrl().'">'.getAuthSubRequestUrl().'</
a>';
//If they gave me a token...
if($_GET['token']){
//Upgrade the given token
$sessionToken =
Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
$yt = new Zend_Gdata_YouTube($httpClient);
// create a Zend_Gdata_YouTube_VideoEntry
$myVideoEntry= new Zend_Gdata_YouTube_VideoEntry();
// set up media group as in the example above
$mediaGroup = $yt->newMediaGroup();
$mediaGroup->title = $yt->newMediaTitle()->setText('Video Upload');
$mediaGroup->description = $yt->newMediaDescription()->setText('Video
description');
// note the different schemes for categories and developer tags
$categoryScheme = 'http://gdata.youtube.com/schemas/2007/
categories.cat';
$developerTagScheme = 'http://gdata.youtube.com/schemas/2007/
developertags.cat';
$mediaGroup->category = array(
$yt->newMediaCategory()->setText('Comedy')-
>setScheme($categoryScheme),
);
$mediaGroup->keywords = $yt->newMediaKeywords()->setText('cars,
funny');
$myVideoEntry->mediaGroup = $mediaGroup;
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($myVideoEntry,
$tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
// place to redirect user after upload
$nextUrl = 'http://apollo.cup.edu/podlab/newtest.php';
// build the form
$form = '<form action="'. $postUrl .'?nexturl='. $nextUrl .
'" method="post" enctype="multipart/form-data">'.
'<input name="file" type="file"/>'.
'<input name="token" type="hidden" value="'. $tokenValue .'"/>'.
'<input value="Upload Video File" type="submit" />'.
'</form>';
}
The Error:
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with
message 'Expected response code 200, got 401' in /Volumes/Aries_2/
webserver/podlab/Zend/Gdata/App.php:468 Stack trace: #0 /Volumes/
Aries_2/webserver/podlab/Zend/Gdata/YouTube.php(520): Zend_Gdata_App-
Volumes/Aries_2/webserver/podlab/newtest.php(100): Zend_Gdata_YouTube-
>getFormUploadToken(Object(Zend_Gdata_YouTube_VideoEntry), 'http://
gdata.yo...') #2 {main} thrown in /Volumes/Aries_2/webserver/podlab/
Zend/Gdata/App.php on line 468
HTTP Response 401 makes me assume I was not correctly authenticated,
any ideas?