无法通过以下链接使用json获取youtube视频说明

时间:2017-02-21 07:37:00

标签: javascript json youtube-api

您好我正在尝试使用videoid获取youtube视频详细信息,但我无法在此获取说明如何获取它。这是我的链接

https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=iwGFalTRHDA&format=json

这是json:

{
  "title": "Trololo",
  "width": 459,
  "height": 344,
  "thumbnail_height": 360,
  "html": "\u003ciframe width=\"459\" height=\"344\" src=\"https:\/\/www.youtube.com\/embed\/iwGFalTRHDA?feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e",
  "thumbnail_width": 480,
  "author_url": "https:\/\/www.youtube.com\/user\/KamoKatt",
  "provider_name": "YouTube",
  "version": "1.0",
  "type": "video",
  "provider_url": "https:\/\/www.youtube.com\/",
  "author_name": "KamoKatt",
  "thumbnail_url": "https:\/\/i.ytimg.com\/vi\/iwGFalTRHDA\/hqdefault.jpg"
}

1 个答案:

答案 0 :(得分:0)

在Youtube的API中使用此终端的视频ID。

https://www.googleapis.com/youtube/v3/videos?part=snippet&id={VIDEO_ID}&fields=items/snippet/title,items/snippet/description&key={YOUR_API_KEY} - jlmcdonald

带有网址的视频:

https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=iwGFalTRHDA&format=json

视频ID为iwGFalTRHDA,现在您只需使用API_KEY即可。如果您没有,则可以按照说明操作,然后启用youtube API并使用提供给您的密钥,从而获得一个here

使用此视频和我的api密钥(我没有把它放在tho下面)

https://www.googleapis.com/youtube/v3/videos?part=snippet&id=iwGFalTRHDA&fields=items/snippet/title,items/snippet/description&key={YOUR_API_KEY}

结果如下:

{
 "items": [
  {
   "snippet": {
    "title": "Trololo",
    "description": ""
   }
  }
 ]
}

这是一段视频ID为e-5obm1G_FY的视频:

{
 "items": [
  {
   "snippet": {
    "title": "Anjana Vakil: Learning Functional Programming with JavaScript - JSUnconf 2016",
    "description": "Slides: https://slidr.io/vakila/learning-functional-programming-with-javascript"
   }
  }
 ]
}