YouTube API - Video Status Check

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mattinahat
Forum Newbie
Posts: 17
Joined: Tue Jul 22, 2008 12:35 pm

YouTube API - Video Status Check

Post by mattinahat »

Hi,

I've been spending a lot of time with the YouTube API recently (more so than my girlfriend) and have used the Zend GData Libraries to upload videos to YouTube, post comments, retrieve comments, like videos etc etc.

The one thing I can't seem to do is get the status of a video upload UNLESS it's at the same time I upload the video, which is no good to me, I need to periodically check every few minutes or so using the video id to retrieve a NEW video object and then check the status against that. As such the original video object that was used to upload no longer exists in memory.

Can anyone help? I've popped the relevant part of the code in below. Really appreciate some help with this one, can't believe I've got this far and stumbling on something that is probably so simple.

Cheers,
M.

Code: Select all

 //create handler
            $httpClient = Zend_Gdata_AuthSub::getHttpClient("--removed--");
            $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $devkey);
            $yt->setMajorProtocolVersion(2);

            //create video entry
            $videoEntry = $yt->getVideoEntry('XQkrAjfOPdw');
           $state = $videoEntry->getVideoState();

if ($state) {
  echo 'Upload status for video ID ' . $videoEntry->getVideoId() . ' is ' .
    $state->getName() . ' - ' . $state->getText() . "\n";
  } else {
    echo "Not able to retrieve the video status information yet. " .
      "Please try again later.\n";
}
mattinahat
Forum Newbie
Posts: 17
Joined: Tue Jul 22, 2008 12:35 pm

Re: YouTube API - Video Status Check

Post by mattinahat »

- sorry should probably say what the errors are - i get all the way through to obtaining the video entry and the getVideoState(); call doesn't result in any errors, it just returns a blank variable in $state.

Apparently if $state is blank that means that there are no upload errors, however I tried the same code on a duplicate video which hadn't been published but still drew a blank even though it should have told me was a duplicate.
Post Reply