使用javascript删除deezer播放列表

时间:2016-01-21 17:41:31

标签: javascript deezer

我尝试执行此操作的方式如下:

var postPlaylistAjax = $.ajax({
    type: 'delete',
    url: 'http://api.deezer.com/user/me/playlists?request_method=delete&
        access_token='+
        encodeURIComponent(deezerAccessToken)+'&playlist_id=' +
        encodeURIComponent(playlistId) + '&output=jsonp',
    dataType: 'jsonp',
    success: function() {
        alert('Deleted');
    },
    error: ajaxError,
});

(当我在网上试用时,结果为真,但它不会删除播放列表。)

由于删除播放列表的API说明如下

request_method = delete

https://api.deezer.com/playlist/ {PLAYLIST_ID}

我在javascript中执行它时遇到了麻烦

1 个答案:

答案 0 :(得分:0)

解决了它:

  function deleteDeezerPlaylist(playlistId) {
                var postPlaylistAjax = $.ajax({
                    type: 'post',
                    url: 'http://api.deezer.com/playlist/'+encodeURIComponent(playlistId)+'?request_method=DELETE&access_token='+encodeURIComponent(deezerAccessToken)+'&output=jsonp',
                    dataType: 'jsonp',
                    error: ajaxError,
                });
                return postPlaylistAjax.then(function (response) {
                    return response.id;
                });
            }