YOUTUBE API中的insertEntry返回什么?

时间:2011-02-18 07:02:14

标签: php youtube youtube-api

我们使用YouTube API将视频上传到YouTube。

$ newEntry = $ yt-> insertEntry($ myVideoEntry,$ uploadUrl,'Zend_Gdata_YouTube_VideoEntry');

上传后,我们如何才能获得刚刚上传的视频的唯一代码? 我的意思是,在网址中, http://www.youtube.com/watch?v=pBI3lc18k8Q

“pBI3lc18k8Q”是视频的唯一代码。那么,如何为我们刚上传的视频获取这个?

2 个答案:

答案 0 :(得分:4)

上传后执行此代码:

// Assuming that $videoEntry is the object that was returned during the upload
$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";
}

答案 1 :(得分:2)

你在$ newEntry中获得了独特的代码! ;)