如何使用SoundCloud API获取所有播放列表

时间:2022-05-28 10:44:09

I'm using the iOS SDK provided by SoundCloud. My issue is the following : i can't get my playlists. Indeed, there a few weeks, everything was working properly but now my jsonResponse object is nil. Here is an excerpt of my code :

我正在使用SoundCloud提供的iOS SDK。我的问题如下:我无法获取播放列表。事实上,有几个星期,一切都正常,但现在我的jsonResponse对象是零。这是我的代码的摘录:

//Get soundcloud account to launch request
SCAccount *account = [SCSoundCloud account];
SCRequestResponseHandler handler;
handler = ^(NSURLResponse *response, NSData *data, NSError *error) {
    NSError *jsonError = nil;
    NSJSONSerialization *jsonResponse = [NSJSONSerialization
                                         JSONObjectWithData:data
                                         options:0
                                         error:&jsonError];
    if (!jsonError && [jsonResponse isKindOfClass:[NSArray class]]) {
        //response treatment
    }

NSString *resourceURL = @"https://api.soundcloud.com/me/playlists.json";
[SCRequest performMethod:SCRequestMethodGET
              onResource:[NSURL URLWithString:resourceURL]
         usingParameters:nil
             withAccount:account
  sendingProgressHandler:nil
         responseHandler:handler];

I don't understand because the two following requests return results:

我不明白,因为以下两个请求返回结果:

  1. /Me (about my soundcloud account)
  2. /我(关于我的soundcloud帐户)

NSString *resourceURL = @"https://api.soundcloud.com/me.json";
Request with this URL return an NSDictionary which contains some informations such as the number of playlists (return 61 playlists)

NSString * resourceURL = @“https://api.soundcloud.com/me.json”;使用此URL的请求返回一个NSDictionary,其中包含一些信息,例如播放列表的数量(返回61个播放列表)

  1. /Tracks (get tracks)
  2. /曲目(获取曲目)

NSString *resourceURL = @"https://api.soundcloud.com/me/tracks.json"; Request with this URL return an NSArray which contains some informations about my tracks

NSString * resourceURL = @“https://api.soundcloud.com/me/tracks.json”;使用此URL的请求将返回一个NSArray,其中包含有关我的曲目的一些信息

So, i am wondering if the url to get all playlists of my account with soundcloud api would not have changed ? Thank you in advance for your answers.

所以,我想知道使用soundcloud api获取我帐户的所有播放列表的网址是否会改变?提前感谢您的回答。

1 个解决方案

#1


1  

Since SoundCloud decided not to maintain anymore this library I created my own one, maybe it could helps you. One of the request I've already implemented is request your playlists:

由于SoundCloud决定不再维护这个库我创建了自己的库,也许它可以帮助你。我已经实施的请求之一是请求您的播放列表:

[self.soundCloudPort requestPlaylistsWithSuccess:^(NSArray *playLists) {
    // Here you have your playlists
} failure:^(NSError *error) {
    // Handle the error
}];

ABMSoundCloud on Github

ABMSoundCloud在Github上

#1


1  

Since SoundCloud decided not to maintain anymore this library I created my own one, maybe it could helps you. One of the request I've already implemented is request your playlists:

由于SoundCloud决定不再维护这个库我创建了自己的库,也许它可以帮助你。我已经实施的请求之一是请求您的播放列表:

[self.soundCloudPort requestPlaylistsWithSuccess:^(NSArray *playLists) {
    // Here you have your playlists
} failure:^(NSError *error) {
    // Handle the error
}];

ABMSoundCloud on Github

ABMSoundCloud在Github上