0
我想讓網絡客戶端可以將視頻添加到播放列表中。目前我不知道什麼是錯誤的,所以幫助是比歡迎。Youtube播放列表插入API Javascript
我得到錯誤代碼400()並檢查了錯誤代碼,但有一點可以確定視頻不在播放列表中。同樣的確切的東西在他們的「嘗試它!」中起作用部分。所以我認爲我的配置變量不正確或即時發送錯誤的方式。
function addSongYTPlaylist(){
var xmlhttp = new XMLHttpRequest();
var url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&part=snippet&key=AIzaSyA17v8PuNBsIwgbxg6D78iHV-w7_dYyXPw";
var config = {
"snippet": {
"playlistId": {PLAYLIST_ID},
"resourceId": {
"videoId": {VIDEO_ID},
"kind": "youtube#video"
}
}
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var response = JSON.parse(xmlhttp.responseText);
console.log(response);
}
};
console.log(url);
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Authorization", "Bearer {ACCESS_TOKEN});
xmlhttp.send(config);
}