从 YouTube 视频中获取标题并将其写入 HTML/CSS

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

我不是最擅长网络编码的,我最近才开始做一个快速项目。我想从 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 支持,不确定其他网站。

My Website

如有错误请更正 ;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;
}