json - 无法获得YouTube视频的标题

标签 json html video youtube

我需要我的博客(blogger)有效的代码,才能使用以下字符串获取YouTube视频的标题:

http://gdata.youtube.com/feeds/api/videos/EDV-KMBvMck?v=2&alt=json&prettyprint=true

(此字符串在Internet Explorer中很好用)

我已经通过各种方法找到了这里,但没有结果显示。

我想在td标签中显示视频的标题。

<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <style>
    table#t01 {
      width: 100%;
    }
    table#t01,
    th,
    td {
      border: 1px solid black;
      border-collapse: collapse;
      text-align: center;
    }
  </style>
</head>

<body>
  <div>
    <table id="t01">
      <col style="width:50%;">
        <col style="width:50%;">
          <tr>
            <td>
              <a href="http://www.youtube.com/embed/EDV-KMBvMck" target="_blank"><img src="https://img.youtube.com/vi/EDV-KMBvMck/default.jpg"" alt="YouTube Icon"></a>
            </td>
            <td>
              <script>
                $Video_Id = 'EDV-KMBvMck'
                $.getJSON("http://gdata.youtube.com/feeds/api/videos/{$Video_Id}?v=2&alt=json&prettyprint=true", function(json) {
                    console.log("success");
                    var items = [];
                    $.each(json. {
                      $Video_Id
                    }, function(key1, val1) {
                      $Value = val1.key + val1.val
                    });
                    echo $Value
                  })
                  .done(function() {
                    console.log("second success");
                  })
                  .fail(function() {
                    console.log("error");
                  })
                  .always(function() {
                    console.log("complete");
                  })
                  .error(function(error) {
                    console.log(error);
                  });
              </script>
            </td>
          </tr>
          <tr>
            <td>
              <a href="http://www.youtube.com/embed/yXL7dT7ovEM" target="_blank"><img src="https://img.youtube.com/vi/yXL7dT7ovEM/default.jpg"" alt="YouTube Icon"></a>
            </td>
            <td>
              <script>
                $Video_Id = 'yXL7dT7ovEM'
                $.getJSON("http://gdata.youtube.com/feeds/api/videos/{$Video_ID}?v=2&alt=json&prettyprint=true", function(json) {
                    console.log("success");
                    var items = [];
                    $.each(json. {
                      $Video_Id
                    }, function(key1, val1) {
                      $Value = val1.key + val1.val
                    });
                    echo $Value
                  })
                  .done(function() {
                    console.log("second success");
                  })
                  .fail(function() {
                    console.log("error");
                  })
                  .always(function() {
                    console.log("complete");
                  })
                  .error(function(error) {
                    console.log(error);
                  });
              </script>
            </td>
          </tr>
    </table>
  </div>
</body>

</html>


我想要一个 header 中的函数,该函数将在Video_Id的每次更改时从td标签调用。

最佳答案

<iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/W-Q7RMpINVo" frameborder="0" allowFullScreen></iframe>

将其粘贴到您的页面并进行必要的更改。它可以在Firefox,MSIE,Chrome,Opera以及几乎所有新浏览器中运行。

关于json - 无法获得YouTube视频的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28209455/

相关文章:

java - Spring 启动 : Wrapping JSON response in dynamic parent objects

json - 将原始 JSON 加载到 Pig 中

html - 使用 emmet 缩写创建颜色

html - 正文背景颜色不适用于电子邮件通讯

python - 如何在 python 中打开和保存视频文件?

ios - 如何在 iOS Swift 3 中将 JSON 字符串转换为字典数组

java - JsonArrayRequest 在 Android Studio 中不起作用 : Can not resolve constructor

html - 通过 CSS "fill"重新着色 SVG 图像不起作用

php - 显示没有图像的视频中的 Jwplayer 预览图像

android - 无尽的视频录制