我正在使用 Javascript 使用 Soundcloud 的 API 为我的作品集创建一个网络应用程序。在我目前的阶段,我需要能够创建一个新的集合(又名播放列表)。我使用的是 Soundcloud 文档中的示例代码:
SC.connect(function() {
var tracks = [22448500, 21928809].map(function(id) { return { id: id } });
SC.post('/playlists', {
playlist: { title: 'My Playlist', tracks: tracks }
});
});
但我收到 422 错误:
Unprocessable Entity - The request looks alright, but one or more of the parameters looks a little screwy. It's possible that you sent data in the wrong format (e.g. an array where we expected a string).
但它看起来并没有缺少任何东西。
最佳答案
除了播放列表标题和轨道之外,对 SoundCloud API 的调用还需要一个回调函数。您的代码应如下所示:
SC.connect(function() {
var tracks = [22448500, 21928809].map(function(id) { return { id: id } });
SC.post('/playlists', {
playlist: { title: 'My Playlist', tracks: tracks }, function(response){
console.log(response)
}
});
});
不幸的是,他们的例子是错误的。
关于javascript - 使用 Soundcloud 的 API 创建 Set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31372837/