Posting comments with Cocoa wrapper.

1 view
Skip to first unread message

Tomasz Dubik

unread,
Nov 2, 2009, 1:59:19 AM11/2/09
to SoundCloudAPI
Hi there,

Is it possible to post new comment to the track with cocoa wrapper ?
I tried to construct parameters dictionary which will be equal to this
one which is presented in documentation example:
<comment>
<body>Yeah!</body>
</comment >

NSMutableDictionary* params = [[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Yeah!", @"body",@"0",nil];
NSMutableDictionary* param = [[NSMutableDictionary alloc] init];
[param setObject:params forKey:@"comment"];

I'm getting SCAPIErrorHttpResponseError, perhaps because parameters
are missing.
I think that initialization of SCPostBodyPart failed with
"SCPostBodyPart with illegal type: NSDictionary" debug entry.

Should I construct parameters in some different way or the posting
comment isn't implemented yet in cocoa wrapper ?

Best regards,
Tomasz Dubik

Ullrich Schäfer

unread,
Nov 2, 2009, 7:53:03 AM11/2/09
to soundc...@googlegroups.com
Hey,

The code you posted should not work at all.

> NSMutableDictionary* params = [[NSMutableDictionary alloc]
> initWithObjectsAndKeys:@"Yeah!", @"body",@"0",nil];

Ok.. we got @"Yeah!" for the key @"body" but what key is @"0" supposed
to be the value for for?

Also it's not possible to do nested dictionaries. So what you really
wanna do is something like this

NSDictionary* params = [NSDictionary
dictionaryWithObjectsAndKeys:@"Hell yeah!", @"comment[body]" ,
nil];
[api performMethod:@"POST"
onResource:@"/tracks/ [ your-track-id ] /comments"
withParameters:params
context:nil];

Let me know if this works for you.

Ullrich

Tomasz Dubik

unread,
Nov 2, 2009, 8:15:15 AM11/2/09
to soundc...@googlegroups.com
Hi Ullrich,

2009/11/2 Ullrich Schäfer <ullrich....@gmail.com>


Hey,

The code you posted should not work at all.

> NSMutableDictionary* params = [[NSMutableDictionary alloc]
> initWithObjectsAndKeys:@"Yeah!", @"body",@"0",nil];

Ok.. we got @"Yeah!" for the key @"body" but what key is @"0" supposed
to be the value for for?

Sorry for this, I tried also with the timestamp for the comment and I forgot to delete this value when I paste code here.

Also it's not possible to do nested dictionaries. So what you really
wanna do is something like this

NSDictionary* params = [NSDictionary
       dictionaryWithObjectsAndKeys:@"Hell yeah!", @"comment[body]" ,
                                                               nil];
[api performMethod:@"POST"
               onResource:@"/tracks/ [ your-track-id ] /comments"
       withParameters:params
                  context:nil];

I think that "comment[body]" is a key word here. I tried to use single dictionary but with "body" key and call failed with SCAPIErrorHttpResponseError.


 Let me know if this works for you.
 
Ullrich

Thanks for quick response.

Best regards,
Tomasz Dubik
 



Tomasz Dubik

unread,
Nov 2, 2009, 8:44:15 AM11/2/09
to SoundCloudAPI

> NSDictionary* params = [NSDictionary
>         dictionaryWithObjectsAndKeys:@"Hell yeah!", @"comment[body]" ,
>                                                                 nil];          
> [api performMethod:@"POST"
>                 onResource:@"/tracks/ [ your-track-id ] /comments"
>         withParameters:params
>                    context:nil];
>
> Let me know if this works for you.
>
> Ullrich

Thanks a lot. It works fine now.

Best regards,

Tomasz Dubik

Ullrich Schäfer

unread,
Nov 2, 2009, 9:09:26 AM11/2/09
to soundc...@googlegroups.com
Nice! :)

/Ullrich
Reply all
Reply to author
Forward
0 new messages