通过api或API CONSOLE将Song上传到SoundCloud

时间:2013-06-24 08:39:49

标签: soundcloud

我正在为Windows应用商店开发一款应用。我想通过它的api或API CONSOLE将Song上传到SoundCloud。怎么做。我无法将音频文件转换为二进制数据

我在Windows 8应用程序中使用此代码

WinJS.xhr({

                    url: "https://api.soundcloud.com/me/tracks.json?client_id=ID",
                    type: "POST",
                    data: {

                        title: "UploadingTesting",
                        asset_data: audioBinary

                    },
                }).done(function (request) {
                    var responseJSON = JSON.parse(request.responseText);

                }, function (err) {
                    console.log(err.responseText);
                });

1 个答案:

答案 0 :(得分:0)

我将JSON对象发布回SoundCloud API(参见here)的成功有限,但是从jQuery的结构中你可能需要将其更改为:

                    url: "https://api.soundcloud.com/me/tracks.json?client_id=ID",
                    type: "POST",
                    contentType:"application/json; charset=utf-8",
                    dataType: JSON,
                    data: {track:
                              {
                               title: "UploadingTesting",
                               asset_data: audioBinary
                              }
                           },
                }).done(function (request) {
                    var responseJSON = JSON.parse(request.responseText);
                }).fail(function (err) {
                    console.log(err.responseText);
                });