2017-02-21 54 views
0

只得到youtube視頻說明您好,我試圖通過使用videoid得到youtube視頻的詳細信息,但我不能得到這個描述,我怎麼能得到它。這裏是我的鏈接無法只通過以下鏈接使用json

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" 
} 
+0

你檢查了這個類似的問題: http://stackoverflow.com/questions/30241276/how-to-get-youtube-video-description-with-video-id –

回答

0

使用視頻ID來自於YouTube API此端點。

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

與URL中的視頻:

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

視頻ID會iwGFalTRHDA,現在你需要的是用你的API_KEY。如果您沒有,您可以按照說明獲取一個here,然後啓用youtube API並使用提供給您的密鑰。

與此視頻ID和我的API密鑰(我還沒有把它放在下面壽)

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" 
    } 
    } 
] 
}