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

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了