使用soundcloud API ios获取特定用户的信息

时间:2014-01-16 14:40:33

标签: ios soundcloud

在Soundcloud的API参考中,我发现要获取用户信息,我必须这样做:

https://api.soundcloud.com/users/iduser.json
/users/{id}

我尝试过:

https://api.soundcloud.com/users/236170/tracks.json

获取用户的曲目,并且它有效。我不明白为什么不起作用:

https://api.soundcloud.com/users/236170.json

我做错了什么?

2 个答案:

答案 0 :(得分:0)

Try this: 

SCAccount *account = [SCSoundCloud account];

    if (account) {

        SCRequestResponseHandler handler1;
        handler1 = ^(NSURLResponse *response, NSData *data, NSError *error) {
            NSError *jsonError = nil;
            NSJSONSerialization *jsonResponse = [NSJSONSerialization
                                          JSONObjectWithData:data
                                          options:0
                                          error:&jsonError];
            if (!jsonError && [jsonResponse isKindOfClass:[NSArray class]])
            {
                NSLog(@"%@",jsonResponse);
            }
        };
        [SCRequest performMethod:SCRequestMethodGET
                    onResource:[NSURL URLWithString:@"https://api.soundcloud.com/me.json"]
                usingParameters:nil
                   withAccount:account
          sendingProgressHandler:nil
                responseHandler:handler1];
    } else
    {
    }

答案 1 :(得分:0)

从您的请求中删除.json

HTTP GET: https://api.soundcloud.com/users/236170?client_id={CLIENT_ID}

响应:

{
  "id": 236170,
  "kind": "user",
  "permalink": "far-too-loud",
  "username": "Far Too Loud",
  "last_modified": "2017/02/06 20:30:18 +0000",
  "uri": "https://api.soundcloud.com/users/236170",
  "permalink_url": "http://soundcloud.com/far-too-loud",
  "avatar_url": "https://i1.sndcdn.com/avatars-000117553632-7ywdqa-large.jpg",
  "country": null,
  "first_name": "Oliver",
  "last_name": "Cash",
  "full_name": "Oliver Cash",
  "description": "Far Too Loud is all about hi-tech, dancefloor-destroying music that makes people throw their hands in the air and go crazy. Think high-energy, aggressive funk with big basslines and crazy edits and you’ll know the sound. \n\nFormed by Oli Cash and Dom Smart back in 2005, their sound quickly won fans and only two years later picked up 'Best Single' at the Breakspoll Awards.  Later that year the FTL anthem 'Play It Loud', which saw a move from breakbeat to dirty electro-house, received a massive response and remains a crowd-pleaser to this day. 2009 saw the duo split with Dom forming techno moniker Neurodriver and Oli continuing with FTL, producing a string of electro chart-smashers including 'Bring Back Boogie' and 'Megaloud'.\n\nThe bass-fueled releases of 2012’s ‘Firestorm’ EP and the follow-up 'Faster Than Light' EP received high praise from all over the bass music scene, bursting with the now familiar big production and energy. Cementing FTL’s place in the bass music scene, these paved the way for more recent releases on heavyweight labels including OWSLA, Never Say Die, Disciple, and Monstercat, and remixes for bass-lords Zomboy, Snails and Pegboard Nerds.\n\nWell experienced in delivering unique sets packed with energy, whether it’s 200 people in a sweaty underground club or 20,000 at an outdoor festival, you can be sure it’s going to go off when FTL is in control!",
  "city": "Brighton",
  "discogs_name": null,
  "myspace_name": null,
  "website": "http://fartooloud.com",
  "website_title": "Website",
  "track_count": 71,
  "playlist_count": 15,
  "online": false,
  "plan": "Pro Plus",
  "public_favorites_count": 2878,
  "followers_count": 118855,
  "followings_count": 1323,
  "subscriptions": [
    {
      "product": {
        "id": "creator-pro-unlimited",
        "name": "Pro Unlimited"
      }
    }
  ],
  "likes_count": 0,
  "reposts_count": 76,
  "comments_count": 87
}