javascript - 使用 Soundcloud 的 API 创建 Set

标签 javascript soundcloud

我正在使用 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/

相关文章:

javascript - 获取 stream_url 的 404 页面。已设置所有权限

audio - SoundCloud,通过 api 下载或流式传输文件

javascript - Mootools1.1 element.$tmp是什么?

javascript - .hover 在鼠标离开时不起作用

python - streamble 为 false 的 soundcloud 轨道的流 URL

javascript - HTML5 自定义播放器不适用于 Soundcloud api uri

audio - Safari不会播放Soundcloud小部件的音频,但只会播放3个文件中的1个

javascript - 如何将 DRY 原则应用于评论?

javascript - Google map 上的 FlowMap 可视化

javascript - 如何以React方式动态注入(inject)div?