我已经尝试过了,但它失败了:
$whereIsMyCake = '';
//
// put all the links here
//
$url = "http://www.youtube.com/embed/more_yougooglelink";
$url = "http://www.youtube.com/v/..." // works
$url = "http://www.youtube.com/watch?v=ue1mLnyEd90"; // WORKS
$url = "http://youtu.be/we_youGoogle_u"; // WORKS
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
if($my_array_of_vars['v']=='') {
preg_match(
"#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#",
$url,
$matches);
$whereIsMyCake = $matches[0];
} else {
$whereIsMyCake = $my_array_of_vars['v'];
}
echo $whereIsMyCake;
问题:现在youtube.com/embed/videoid is here
似乎不起作用,如果 youtube 建立新链接,我们必须不断改变我们的算法怎么办?为了youtube.com/embed/embed.weareruling/embed/embed/googleisboss/findmenow/video id is here ?