YouTube API getVideoId 为空
我使用基于浏览器的上传方法上传一些视频。视频上传正常,但我无法获取最近上传的视频的 ID。 这就是我所做的:
$vidEntry = new Zend_Gdata_YouTube_VideoEntry();
...
...
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($vidEntry, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
...
...
posting using cURL...
还有有问题的代码:
$state = $vidEntry->getVideoState();
if($state) {
$video_id = $vidEntry->getVideoId();
} else {
die("Error");
}
这里的 $state 是 NULL。有什么问题吗?
顺便说一句,根据手册:
上传视频文件后,用户被重定向到下一个url 在您的表格中指定。如果上传成功,YouTube 会追加 URL 的 id 和状态参数,如以下示例所示:
但我仍然无法获取它们(也许我想到了错误的 URL?)。
I upload some video using Browser-based upload method. The video is uploaded fine, however I can't manage to fetch this recently uploaded video's id.
Here's what I did:
$vidEntry = new Zend_Gdata_YouTube_VideoEntry();
...
...
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($vidEntry, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
...
...
posting using cURL...
And the problematic code:
$state = $vidEntry->getVideoState();
if($state) {
$video_id = $vidEntry->getVideoId();
} else {
die("Error");
}
And the $state here is NULL. What's the problem?
BTW according to manual:
After uploading the video file, the user is redirected to the nexturl
specified in your form. If the upload was successful, YouTube appends
id and status parameters to the URL as shown in the following example:
But I still can't get them (Maybe I'm thinking of the wrong URL?).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在基于浏览器的上传中,您的代码在视频尚未上传时起作用。所以此时无法知道VIDEO_ID。
为了获取 VIDEO_ID,您必须查看着陆页上传入的 GET 参数中的 Id 参数。
着陆页必须以表单操作链接中的“?nexturl=”参数形式提供给 youtube。
In browser-based uploading your code works at the time when video hasn't been uploaded yet. So it is not possible to know the VIDEO_ID at this time.
In order to get the VIDEO_ID you have to look at Id parameter among incoming GET parameters on your landing page.
Landing page have to be provided to youtube as "?nexturl=" parametar in form action link.
解决了。我只是做了错误的重定向。
Solved. I was just doing a wrong redirect.