你可以做一個HTTP POST到這個地址:
http://www.youtube.com/oembed?url={complete youtube url}&format=json
其中{完成YouTube網址}是視頻的完整URL。
例如:
http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=AJ0sW7KOFhU&format=json
應該回答你這個JSON:
{
author_url: "http://www.youtube.com/user/neiljohnson666",
version: "1.0",
provider_name: "YouTube",
provider_url: "http://www.youtube.com/",
thumbnail_url: "http://i2.ytimg.com/vi/AJ0sW7KOFhU/hqdefault.jpg",
author_name: "Neil Johnson",
type: "video",
width: 480,
height: 270,
title: "Manowar - Warriors of the World HD",
thumbnail_width: 480,
html: "<iframe width="480" height="270" src="http://www.youtube.com/embed/AJ0sW7KOFhU? feature=oembed" frameborder="0" allowfullscreen></iframe>",
thumbnail_height: 360
}
所以thumbnail_url是你正在尋找的形象:
希望幫助,歡呼!
謝謝。這有一點幫助。它很酷是的。我還可以獲得時間視頻是多久? – StefMa
當然,試試這個:http://gdata.youtube.com/feeds/api/videos/AJ0sW7KOFhU?v=2&alt=jsonc其中AJ0sW7KOFhU是YouTube視頻ID,有一個視頻持續時間字段 –
謝謝。好幫手! – StefMa