json - 使用 alt=json-in-script&callback 检索信息 V3 youtube API

标签 json callback youtube-api youtube-javascript-api

有人知道如何使用 V3 API 来完成此操作吗?

此示例使用 V2

http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?v=2&alt=json-in-script&callback=whatever

回调是

<script type="text/javascript">function youtube' . $random . '(data){document.getElementById(\'title' . $code . '\').title = data.entry[ \'title\' ].$t.substr(0,100);}</script>

最佳答案

Vadim 解决方案不起作用(至少对我来说)。答案就在这里https://developers.google.com/youtube/v3/sample_requests

示例:

https://www.googleapis.com/youtube/v3/videos?id=qzaBVoti3U0&key=[YOURAPIKEY]&part=snippet,contentDetails,statistics,status

将返回如下数据:

{
 "kind": "youtube#videoListResponse",
 "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/kvqkY8X2aXhk-O8BnczihZb8PG8\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#video",
   "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/ZCKauTkB1Y03qtXLwyD0nf4m7gY\"",
   "id": "qzaBVoti3U0",
   "snippet": {
    "publishedAt": "2015-03-17T01:44:05.000Z",
    "channelId": "UC4yfiEBmRDMyk4LuJH7Ckzg",
    "title": "Road Rash 3DO - Level 1 Completo",
    "description": "►REVIEW no Memória BIT http://wp.me/p4n6ZH-2eu ◄\n\nRoad Rash era show de diversão no Mega Drive e a versão 3DO não mudou isto em nada. Confira o gameplay completo do Level 1, incluindo intro e algumas cenas intermediárias. \nControle: Daniel Lemes\n*****\nRoad Rash was pure fun on Sega Genesis, so as the 3DO version. Check out this gameplay including full Level 1, intro and some cutscenes. \nControls: Daniel Lemes.\n\n\n©  1994 Electronic Arts - ALL RIGHTS RESERVED\n© 1991-1994 A&M Records - ALL RIGHTS RESERVED",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/qzaBVoti3U0/default.jpg",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/qzaBVoti3U0/mqdefault.jpg",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "https://i.ytimg.com/vi/qzaBVoti3U0/hqdefault.jpg",
      "width": 480,
      "height": 360
     },
     "standard": {
      "url": "https://i.ytimg.com/vi/qzaBVoti3U0/sddefault.jpg",
      "width": 640,
      "height": 480
     },
     "maxres": {
      "url": "https://i.ytimg.com/vi/qzaBVoti3U0/maxresdefault.jpg",
      "width": 1280,
      "height": 720
     }
    },
    "channelTitle": "Memória BIT",
    "categoryId": "20",
    "liveBroadcastContent": "none",
    "localized": {
     "title": "Road Rash 3DO - Level 1 Completo",
     "description": "►REVIEW no Memória BIT http://wp.me/p4n6ZH-2eu ◄\n\nRoad Rash era show de diversão no Mega Drive e a versão 3DO não mudou isto em nada. Confira o gameplay completo do Level 1, incluindo intro e algumas cenas intermediárias. \nControle: Daniel Lemes\n*****\nRoad Rash was pure fun on Sega Genesis, so as the 3DO version. Check out this gameplay including full Level 1, intro and some cutscenes. \nControls: Daniel Lemes.\n\n\n©  1994 Electronic Arts - ALL RIGHTS RESERVED\n© 1991-1994 A&M Records - ALL RIGHTS RESERVED"
    }
   },
   "contentDetails": {
    "duration": "PT24M47S",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": false,
    "regionRestriction": {
     "blocked": [
      "DE"
     ]
    }
   },
   "status": {
    "uploadStatus": "processed",
    "privacyStatus": "public",
    "license": "youtube",
    "embeddable": true,
    "publicStatsViewable": true
   },
   "statistics": {
    "viewCount": "48",
    "likeCount": "1",
    "dislikeCount": "0",
    "favoriteCount": "0",
    "commentCount": "2"
   }
  }
 ]
}

关于json - 使用 alt=json-in-script&callback 检索信息 V3 youtube API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29575665/

相关文章:

java - POST 请求 JSON 解析器 Java

c# - JSON.NET 错误检测到类型的自引用循环

c# - 如何在 ASP.NET MVC 中创建 Webhook?

google-api - Youtube API v3 获取评论

android - 在WebView android中播放youtube视频

java - 带有状态代码的非 Jersey JAX-RS 自定义异常

javascript - 将 Html 表转换为 JSON

javascript - 如何正确调用setState(updater[,callback])中的回调?

java - Android JSON API 调用

javascript - 使用 toggleClass 暂停/播放 YouTube 视频 API