我想让用户能够添加视频,但我遇到了其中一个网站的问题。从IFrame获取URL?
我将允许来自Youtube,Vimeo,Vevo,Daily Motion和MTV的视频。
问题在于MTV。 URL总是不同的,所以我想知道是否有方法获得IFrame /嵌入代码的源值。
例子:MTV嵌入代码是:
<div style="background-color:#000000;width:520px;">
<div style="padding:4px;">
<iframe src="http://media.mtvnservices.com/embed/mgid:uma:videolist:mtv.com:1687162/cp~instance%3Dfullepisode%26autoPlay%3Dfalse%26series%3D2211%26seriesId%3D29240%26channelId%3D1%26id%3D1687162%26instance%3Dfullepisode%26uri%3Dmgid%3Auma%3Avideolist%3Amtv.com%3A1687162" width="512" height="288" frameborder="0"></iframe>
<p style="text-align:left;background-color:#FFFFFF;padding:4px;margin-top:4px;margin-bottom:0px;font-family:Arial, Helvetica, sans-serif;font-size:12px;">Get More:
<a href="http://www.mtv.com/shows/teen_mom/season_4/series.jhtml" style="color:#439CD8;" target="_blank">Teen Mom (Season 4)</a>, <a href="http://www.mtv.com/videos/home.jhtml" style="color:#439CD8;" target="_blank">Full Episodes</a></p></div></div>
有没有一种方法,我可以得到的IFrame源值指出,完整的字符串?
我只是想:
http://media.mtvnservices.com/embed/mgid:uma:videolist:mtv.com:1687162/cp~instance%3Dfullepisode%26autoPlay%3Dfalse%26series%3D2211%26seriesId%3D29240%26channelId%3D1%26id%3D1687162%26instance%3Dfullepisode%26uri%3Dmgid%3Auma%3Avideolist%3Amtv.com%3A1687162
任何帮助,将不胜感激。其他视频源很简单,因为我能够使用物理URL本身而不是嵌入代码。
DOM文档似乎是一个非常合适的方法,并为我工作:http://stackoverflow.com/questions/8244508/php-extract-youtube-video-ids-from-array-of-iframe-object -embeds – Jake