Do I need Developer’s key for using oembed for youtube in my website?
The problems is that following code does not works, It does not returns to succes
$.ajax({
url: "http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=PVzljDmoPVs",
dataType: "jsonp",
timeout: 15000,
success: function (jo) {
if (jo) {
setIMg(jo.thumbnail_url);
setTitle(jo.title);
}
}
});
But when i fire the url in the browser then it gives me the json:
{"provider_url": "http:\/\/www.youtube.com\/", "thumbnail_url": "http:\/\/i1.ytimg.com\/vi\/PVzljDmoPVs\/hqdefault.jpg", "title": "David Guetta - She Wolf (Falling To Pieces) ft. Sia", "html": "\u003ciframe width=\"480\" height=\"270\" src=\"http:\/\/www.youtube.com\/embed\/PVzljDmoPVs?fs=1\u0026feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e", "author_name": "davidguettavevo", "height": 270, "thumbnail_width": 480, "width": 480, "version": "1.0", "author_url": "http:\/\/www.youtube.com\/user\/davidguettavevo", "provider_name": "YouTube", "type": "video", "thumbnail_height": 360}
Firstly no, you don’t need a developer key to use the oembed endpoints of YouTube.
Secondly, YouTube doesn’t support JSONP on its oEmbed endpoint, that’s the reason your call fails. In order to fix it, you can use a third party oEmbed provider such as reEmbed.me
Here is the sample code:
Note that the link being passed is the actual video url, not the oembed endpoint link.