close
$(function () { //var videoID = 'nUUVkiXFbO0'; var videoURL='<%= videoURL%>'; var video = videoURL.split('v='); var videoID = video[1].substring(0, 11); $.ajax({ url: "https://www.googleapis.com/youtube/v3/videos?id=" + videoID + "&key={YOUTUBE-API-KEY}&part=snippet", cache: false, dataType: "json", success: function (data) { var result = data['items']['length']; if (result > 0) { alert('good'); } else { alert('err'); } }, error: function (request, status, error) { alert(status + ", " + error); } }); })
https://www.googleapis.com/youtube/v3/videos?id=<video_id>&key=<YOUR_API_KEY>&part=snippet
//var videoID = 'kn8yzJITdvI';//not working var videoID ='p4kIwWHP8Vc';//working $.getJSON('http://gdata.youtube.com/feeds/api/videos/'+videoID+'?v=2&alt=jsonc',function(data,status,xhr){ alert(data.data.title);}).error(function(){ alert("error");});
全站熱搜