从YouTube视频中获取标题并用HTML/CSS编写


Getting title from a YouTube video and write it in HTML/CSS

我不是最擅长web编码的人,我最近只是为了一个快速项目才开始使用它。我想从YouTube视频中提取标题,并将其存储在一个变量中,我可以将其写入其中。我以前从未使用过PHP,我在Java和Python方面很有经验,尽管我不知道如何在我的网站上设置它。

index.html:

<html>
  <link rel="stylesheet" type="text/css" href="style.css">  
  <iframe width="1" height="1" src="https://www.youtube.com/embed/videoseries?list=PLsVV8G4dmXyE2mSm3ZSz_AcNVduhw2ZwM&rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>   
</html>

style.css:

body {
background-image: url("http://i.imgur.com/z6fgaW8.png");
background-color: #cccccc;
background-size: 100% 100%;
background-repeat: no-repeat;
}

我的视频在播放列表中,以澄清:id喜欢从YouTube API中提取title,并将其写在网站的左下角。

我的网站确实支持PHP,不确定其他的。

我的网站

请更正任何错误;D谢谢!

您可以使用此代码

$result = json_decode(file_get_contents(sprintf('http://www.youtube.com/oembed?url=%s&format=json', urlencode($url))));
if ($result) {
    $title = $result->title;
    $html = $result->html;
    $thumbnail_url = $result->thumbnail_url;
    $height = $result->height;
    $width = $result->width;
    $thumbnail_width = $result->thumbnail_width;
    $thumbnail_height = $result->thumbnail_height;
}