如何使用 CodeIgniter 获取 youtube 嵌入代码?
我需要提供将 YouTube 视频嵌入到我正在开发的网站中的可能性。管理员应该能够在表单中插入 YouTube 链接; url 将存储在数据库中,然后我必须将其嵌入页面中。
我试图使用这个库:http://codeigniter.com/wiki/YouTube_API_for_CodeIgniter/revision/ 12072/
但是使用 getVideoEntry 函数我得到了这个,我真的不知道如何处理它:
tag:youtube.com,2008:video:zol2MJf6XNE2009-01-14T17:21:57.000Z2011-09-01T11:36:39.000ZSyndication of this video was restricted by its owner.DominoRecordshttp://gdata.youtube.com/feeds/api/users/dominorecordsMusicDominoRecordsA video for 'My Girls' from Animal Collective's new album Merriweather Post Pavilion. Out now on Domino. Produced by: Knowmore Productions Animated by: Jon Vermilyea Edited/VFX by: Chad Von Nauanimal collective, my girls, domino, avey tare, panda bear, geologistDEAnimal Collective - My Girls (2009)widescreen2009-01-14T17:21:57.000Zzol2MJf6XNE
无论如何,使用它,我需要 youtube 视频 ID。有没有一种简单的方法来获取它,涵盖所有可能的 YouTube 网址变体?
I need to give the possibility to embed youtube videos in a website I'm developing. The admin shoud be able to insert a youtube link in a form; the url will be stored in the database and then I have to embed it in a page.
I was trying to use this library: http://codeigniter.com/wiki/YouTube_API_for_CodeIgniter/revision/12072/
But using the getVideoEntry function I get this, and I don't really know what to do with it:
tag:youtube.com,2008:video:zol2MJf6XNE2009-01-14T17:21:57.000Z2011-09-01T11:36:39.000ZSyndication of this video was restricted by its owner.DominoRecordshttp://gdata.youtube.com/feeds/api/users/dominorecordsMusicDominoRecordsA video for 'My Girls' from Animal Collective's new album Merriweather Post Pavilion. Out now on Domino. Produced by: Knowmore Productions Animated by: Jon Vermilyea Edited/VFX by: Chad Von Nauanimal collective, my girls, domino, avey tare, panda bear, geologistDEAnimal Collective - My Girls (2009)widescreen2009-01-14T17:21:57.000Zzol2MJf6XNE
And anyway, to use it, I need the youtube video id. Is there an easy way to get it, which covers all possible variations of youtube urls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CodeIgniter 对于仅仅嵌入视频来说似乎有点矫枉过正。您链接的页面上的 YouTube 功能主要是 YouTube 数据 API 的包装(它允许提取有关 YT 用户、频道、视频等的信息,并促进视频的程序上传)。 嵌入视频就像在页面上放置一些 HTML 一样简单正确的视频 ID。
这是我见过的从 URL 获取视频 ID 的最佳答案。
CodeIgniter seems like overkill for merely embedding videos. The YouTube functionality on the page you linked is mostly a wrapper for the YouTube Data API (which allows for extracting information about YT users, channels, videos, etc. and facilitates procedural uploading of videos). Embedding videos is as easy as dropping some HTML on your page with the correct video ID.
Here's the best answer I've seen for getting the video ID from URLs.