사용자가 동영상을 추가 할 수있게하고 싶지만 사이트 중 하나에 문제가 있습니다.IFrame에서 URL을 가져 오시겠습니까?
YouTube, Vimeo, Vevo, Daily Motion 및 MTV의 비디오를 허용합니다.
문제는 MTV입니다. URL은 항상 다르므로 IFrame/소스 코드의 소스 값을 가져 오는 방법이 있는지 궁금합니다.
예 : MTV의 소스 코드는 다음과 같습니다 내가 그 완전한 문자열 밖으로 IFrame을 소스 값을 얻을 수있는 방법은
<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>
있습니까?
난 그냥 원하는 :
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
어떤 도움을 주시면 감사하겠습니다. 다른 비디오 소스는 embed 코드가 아닌 실제 URL 자체를 사용할 수 있었기 때문에 간단했습니다.
$root = simplexml_load_string($embed_code);
$url = (string) $root->div->iframe['src'];
DOMDocument를 꽤 적절한 방법 같은 것, 그리고 나를 위해 일한 : http://stackoverflow.com/questions/8244508/php-extract-youtube-video-ids-from-array-of-iframe-object -embeds – Jake