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.


  <link rel="stylesheet" type="text/css" href="style.css">  

  <iframe width="1" height="1" src="" frameborder="0" allowfullscreen></iframe>   


body {
background-image: url("");
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('', 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;
    点赞 打赏 评论

相关推荐 更多相似问题