Youtubevideo持续时间API v3
嘿伙计们,我对youtube的api v3有点问题。
问题是,如果json有这种结构
{ "kind": "youtube#videoListResponse", "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/1jshwBhrF6O49W3oUmNF7rmkgAQ\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [ { "kind": "youtube#video", "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/Zji9LPuiDCpb4GjgPpzdGgf85ws\"", "id": "3wFq1-pK05o", "contentDetails": { "duration": "PT1M1S", "dimension": "2d", "definition": "hd", "caption": "true", "licensedContent": true } } ] }
我希望获得这样的video时长 ?
$.getJSON( "https://www.googleapis.com/youtube/v3/videos?id=XXXX&key=XXXXX&part=contentDetails", function( json ) { document.write( "JSON Data: " + json["items"]["contentDetails"]["duration"] ); });
但它不起作用! 我不明白什么是错的。 在我发疯之前请帮助我。
试试这个:
var json = { "kind": "youtube#videoListResponse", "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/1jshwBhrF6O49W3oUmNF7rmkgAQ\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [{ "kind": "youtube#video", "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/Zji9LPuiDCpb4GjgPpzdGgf85ws\"", "id": "3wFq1-pK05o", "contentDetails": { "duration": "PT1M1S", "dimension": "2d", "definition": "hd", "caption": "true", "licensedContent": true } }] } console.log(json.items[0].contentDetails.duration);
- aJax REST API调用 – 当aJax失败时,Curl工作
- Yahoo Weather,Yahoo GeoPlant,Google Weather或其他用javascript连接的API?
- 获取照片集的JQuery / Flickr API问题
- 没有“Access-Control-Allow-Origin”标头但无法访问API
- 如何通过JavaScript管理Google帐户的联系人?
- Ajax调用触发错误事件但返回200 ok
- 使用基本的json获取twitter api
- Zillow API错误:“没有’Access-Control-Allow-Origin’标题存在”
- 如何使用jquery对api进行jsonp调用