doutang3760 2015-11-19 16:37
浏览 17
已采纳

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

I'm not the best at web coding, I've only gotten into it recently for a quick project. I'm looking to pull the title from the YouTube video and store it in a variable to which I can write out. Ive never used PHP before, I'm experienced In Java and Python although I have no idea how to set it up on my website.

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;
}

My videos are in a playlist, to clarify: id like to pull the title from the YouTube API and write this in the bottom left corner of the website.

My website does have PHP support, not sure about the others.

My Website

Please correct any errors ;D Thankyou!

  • 写回答

1条回答 默认 最新

  • dongzhukuai8177 2015-11-19 16:48
    关注

    You can use this code

    $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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况