使用 Soundcloud 的 API 创建一个集合
Creating a Set With Soundcloud's API
我正在使用 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 的网络应用程序。在我目前的阶段,我需要能够创建一个新的集合(又名播放列表)。我使用的是 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)
}
});
});
不幸的是,他们的例子是错误的。