开发者

How to get youtube embed code with CodeIgniter?

开发者 https://www.devze.com 2023-04-01 22:35 出处:网络
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

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-1开发者_如何转开发4T17: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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消