SitePoint Sponsor |
|
User Tag List
Results 1 to 1 of 1
Thread: Zend_Gdata_YouTube insertEntry
-
Nov 8, 2009, 04:52 #1
- Join Date
- May 2006
- Location
- Kakiland
- Posts
- 732
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Zend_Gdata_YouTube insertEntry
Hi.
The task
I should upload multiple flv files into youtube service
in background.
In the cms the moderator can decide if a video can be upload or not
in the cideo table I've got all the informatins for the upload
plus a field type enum default no_put named video_status
if the moderator decide don't put the movie video_status is set no_put
if the moderator decide to put the movie video_status is se to_put
on click a xhr request set the video_status to_put
in a cron I retrieve video with flag to_put
and upload them into you service
onsuccess set video_status put
onerror set video_status log_put (for example) and log the error
First I'd like to know your opinion about this set up.
Second I followed the reference and I update this snippet
(I'm going to put this in a loop)
PHP Code:$yt = new Zend_Gdata_YouTube(getAuthSubHttpClient());
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource('intro.flv');
$filesource->setContentType('video/x-flv');
$filesource->setSlug('intro.flv');
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// Note that category must be a valid YouTube category !
$myVideoEntry->setVideoCategory('Comedy');
// Set keywords, note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');
// Optionally set some developer tags
$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag',
'anotherdevelopertag'));
// Optionally set the video's location
$yt->registerPackage('Zend_Gdata_Geo');
$yt->registerPackage('Zend_Gdata_Geo_Extension');
$where = $yt->newGeoRssWhere();
$position = $yt->newGmlPos('37.0 -122.0');
$where->point = $yt->newGmlPoint($position);
$myVideoEntry->setWhere($where);
// Upload URI for the currently authenticated user
$uploadUrl =
'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
// Try to upload the video, catching a Zend_Gdata_App_HttpException
// if availableor just a regular Zend_Gdata_App_Exception
try {
$newEntry = $yt->insertEntry($myVideoEntry,
$uploadUrl,
'Zend_Gdata_YouTube_VideoEntry');
echo "
";
print_r($newEntry);
}
catch (Zend_Gdata_App_HttpException $httpException) {
/* Manage Error */
echo $httpException->getRawResponseBody();
}
catch (Zend_Gdata_App_Exception $e) {
/* Manage Error */
echo $e->getMessage();
you tube service.
My trouble is how to check
if a video has been successfully uploaded or not
(I think to manage this in the catch scope /* Manage Error */ ????? )
and retrieve the video entry (like Browser-based upload)?
Bye.
Bookmarks