YouTube PHP API - Getting the status of a previously uploaded video?

Just started digging into the PHP API on YouTube and got a browser-based download of the Zend script. However, I can’t find the documentation on how to get the status of the video after downloading it. The main reason I need this is error handling - I need to know if the video is approved on YouTube, as someone can technically upload an image or file is too large. I need to know that vid has been approved so that I know what message the end user displays when they return to the site (i.e. "Your live video" or "Video upload error").

YouTube browser-based loading in PHP returns the status of the URL parameter 200, even if the format or size is incorrect, which of course does not help. Any ideas on how else to get this information from the YT object?

In general, when a user returns to the site, I want to be able to create a YT object based on their specific video ID and I want to be able to confirm that it was not rejected. I use ClientLogin to launch YouTube obj:

$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
              $username = 'myuser@gmail.com',
              $password = 'mypassword',
              $service = 'youtube',
              $client = null,
              $source = 'MySource', // a short string identifying your application
              $loginToken = null,
              $loginCaptcha = null,
              $authenticationURL);

Any thoughts?

+5
source share
2 answers

Whit finally found the answer to this question after searching and compiling the code in the last few days. After creating the object $ytfor checking the status, perform the following actions:

$yt->setMajorProtocolVersion(2);
$youtubeEntry = $yt->getVideoEntry('YOUR_YOUTUBE_VID_ID', null, true);

if ($youtubeEntry->getControl()){
    $control = $youtubeEntry->getControl();
    $state = $control->getState()->getName();
}

$state 'failed', - . , , , . (, : , , , , , Mient-jan Stelling).

, API- YouTube. ! ( )

+4

CallToken, .

Zend_Gdata_Youtube Zend AuthSub.

CallToken, .

$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
          $username = 'myuser@gmail.com',
          $password = 'mypassword',
          $service = 'youtube',
          $client = null,
          $source = 'MySource', // a short string identifying your application
          $loginToken = null,
          $loginCaptcha = null,
          $authenticationURL);

$youtube = new Zend_Gdata_YouTube( $httpClient, '', NULL, YOUTUBE_DEVELOPER_KEY );

$youtubeEntry = $youtube->getFullVideoEntry( 'ID_OF_YOUTUBE_MOVIE' ); 
// its the 11 digit id all youtube video have

$youtubeEntry

$state = $youtubeEntry->getVideoState();

null, , ​​.

(string) $state->getName();

4 . (, , , )

+1

All Articles