【发布时间】:2016-06-21 02:21:58
【问题描述】:
我正在尝试编写一个 JavaScript 代码,该代码可以通过在 var 中输入视频的 ID 来检测视频的许可证。因此,我查看了 youtube API 的官方页面,并想出了这个 url
https://www.googleapis.com/youtube/v3/videos?id=gwLej8heN5c&part=status&key= { 我的 API 密钥 }
这将返回这个结果
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "creativeCommon",
"embeddable": true,
"publicStatsViewable": true
这对我有好处,因为我得到了“license: creativeCommon”但是我不能把它带入 JavaScript 函数。 注意:我尝试对其进行 iframe,但是即使将 &output=embed 添加到代码中,它也不会在 iframe 中显示任何内容。
为了说明这一点,我打算用它来做:
var result = // somehow to get the result from the API
function licensetype() {
var cheack = result.search("creativeCommon");
if ( cheack = -1 ) {
document.write("This video is not a creative Common");
} else {
document.write (" This video is a creativeCommon" );
那么有没有办法让我在 javascript 变量中得到上面显示的结果?
【问题讨论】:
-
不确定你的意思。请分享一些您如何调用 API 的代码?
-
这是我的问题,我正在尝试找到一种调用 API 的方法,并附上了我打算使用它的示例代码。
标签: javascript youtube-api youtube-javascript-api