1
這個問題困擾了我一天,沒有關於soundcoud的任何關聯的Cocoa代碼示例。感覺被擊敗,我希望能得到您的幫助Soundcloud將歌曲添加到播放列表(ios)
這個問題困擾了我一天,沒有關於soundcoud的任何關聯的Cocoa代碼示例。感覺被擊敗,我希望能得到您的幫助Soundcloud將歌曲添加到播放列表(ios)
我用AFNetworking這裏這個例子中得到的一切工作:https://github.com/soundcloud/soundcloud-ruby
[parameters setObject:@"YOUR TOKEN" forKey:@"oauth_token"];
[[AFNetworkingClient sharedClient] GET:[NSString stringWithFormat:@"me/playlists/%@.json",@"Some ID"] parameters:parameters
success: ^(NSURLSessionDataTask *task, id responseObject)
{
NSMutableArray * ids = [[NSMutableArray alloc]init];
for (id trackDictionary in [responseObject objectForKey:@"tracks"]) {
Track * track = [[Track alloc]initWithDictionary:trackDictionary error:nil];
[ids addObject:track.id];
} // Get all IDS
[ids addObject:@"NEW ID"]; // Add the new ID to the array
NSMutableArray * idArray = [[NSMutableArray alloc]init];
for (NSNumber *idNumber in ids) {
[idArray addObject:@{@"id":idNumber}]; // Create an Array of Dictionarys
} //[{@"id":23232},{@"id":345454}]
NSMutableDictionary * parameters = [[NSMutableDictionary alloc]init];
[parameters setObject:@"YOUR TOKEN"];
[parameters setObject:@{@"tracks":idArray} forKey:@"playlist"];
[[AFNetworkingClient sharedClient] PUT:[NSString stringWithFormat:@"me/playlists/%@.json",playlist.id] parameters:parameters
success: ^(NSURLSessionDataTask *task, id responseObject)
{
}
failure: ^(NSURLSessionDataTask *task, NSError *error)
{
}];
}
failure: ^(NSURLSessionDataTask *task, NSError *error)
{
}];
爲了將歌曲添加到播放列表中,您需要發出與'HTTP PUT請求跟蹤包含曲目的屬性。你嘗試過嗎?你有沒有嘗試使用iOS SDK? – 2014-10-13 07:24:24