1
我試圖使用V3搜索API(https://www.googleapis.com/youtube/v3/search)檢索有關YouTube視頻的詳細信息。我在我的JSON響應中獲取了所有視頻的詳細信息,但不是視頻的網址。有人可以幫助我如何檢索網址?提前致謝。如何從YouTube V3 api檢索URL值?
我試圖使用V3搜索API(https://www.googleapis.com/youtube/v3/search)檢索有關YouTube視頻的詳細信息。我在我的JSON響應中獲取了所有視頻的詳細信息,但不是視頻的網址。有人可以幫助我如何檢索網址?提前致謝。如何從YouTube V3 api檢索URL值?
在JSON中沒有視頻網址,您需要使用videoId。
例如,你有這樣一個結果:
{
"kind": "youtube#searchListResponse",
"etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/KciEh2k6bPhgTexCFr55nrDyEuo\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1031,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/1Y85a6l1YSEQprOw66ptMsh0Bzw\"",
"id": {
"kind": "youtube#video",
"videoId": "KG0vtEsiPgs"
},
"snippet": {
"publishedAt": "2015-01-04T20:06:53.000Z",
"channelId": "UC5nc_ZtjKW1htCVZVRxlQAQ",
"title": "Real Slow - You Flow",
"description": "That little vocal snippet has got me hooked :) Download... http://bit.ly/1xHDPlX Real Slow https://soundcloud.com/realslowbeats ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/KG0vtEsiPgs/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/KG0vtEsiPgs/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/KG0vtEsiPgs/hqdefault.jpg"
}
},
"channelTitle": "MrSuicideSheep",
"liveBroadcastContent": "none"
}
},
{
然後你就可以提取視頻ID創建的URL鏈接YouTube的視頻。
對於爲例items[0].id.videoId
給我KG0vtEsiPgs
然後,你需要這個網址https://www.youtube.com/watch?v=
來串聯videoId
:
https://www.youtube.com/watch?v= '視頻ID'
然後你有視頻鏈接。
像魅力一樣工作......感謝一個好人! – user318197 2015-01-27 07:01:50