php 如何获取通过 Youtube API 上传视频的日期?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1699099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get the date a video was uploaded through the Youtube API?
提问by J3nnings
I'm confused as to where I can find the date a youtube video was uploaded. I've been using the following two functions:
我不知道在哪里可以找到上传 YouTube 视频的日期。我一直在使用以下两个功能:
$videoEntry->getUpdated()->getText();
$videoEntry->getVideoRecorded()
The first is when the video was last updated, and I'm not so sure that is the same as when it was uploaded. The "video recorded" is not always present. I assume its taken from camera metadata.
第一个是视频上次更新的时间,我不确定这是否与上传时相同。“录制的视频”并不总是存在。我假设它取自相机元数据。
I need the date it was uploaded to the youtube website. Thanks.
我需要它上传到 youtube 网站的日期。谢谢。
采纳答案by J3nnings
I was actually hoping for an answer through the PHP API specifically. None of the functions in the documentation were working, though I was able to get the date uploaded from PHP like so:
我实际上特别希望通过 PHP API 得到答案。文档中的所有函数都没有工作,尽管我能够像这样从 PHP 获取上传的日期:
$videoEntry->mediaGroup->uploaded->text
回答by Ralph Lavelle
From the YouTube API Reference Guide.
"The <yt:uploaded>tag specifies the time that a playlist entry was originally uploaded to YouTube."
“该<yt:uploaded>标签指定播放列表条目最初上传到 YouTube 的时间。”
If you just browse the feed file for a particular video, such as http://gdata.youtube.com/feeds/api/videos/bTL5bErRk-g, you can see the uploaded date in the "published" tag, near the top:
如果您只是浏览特定视频的供稿文件,例如http://gdata.youtube.com/feeds/api/videos/bTL5bErRk-g,您可以在靠近顶部的“已发布”标签中看到上传日期:
<entry>
<id>http://gdata.youtube.com/feeds/api/videos/bTL5bErRk-g</id>
<published>2009-08-02T13:59:54.000Z</published>
<updated>2009-10-29T11:20:11.000Z</updated>
...
Whatever 'published' technically means to YouTube, that's my video, and I can confirm that that's when I uploaded it.
无论“发布”在技术上对 YouTube 意味着什么,这就是我的视频,我可以确认那是我上传它的时间。
回答by freakk69
Latest Youtube API supports date.
最新的 Youtube API 支持日期。
https://developers.google.com/youtube/v3/docs/search/list#examples
https://developers.google.com/youtube/v3/docs/search/list#examples
回答by georgiecasey
For Youtube V3, it's something like this:
对于 Youtube V3,它是这样的:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=(youtube_video_id)&key=(your_oauth_key)
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=(youtube_video_id)&key=(your_oauth_key)
"publishedAt" seems to have the date and time of publication in UTC timezone
"publishedAt" 似乎有 UTC 时区的发布日期和时间

