views:

259

answers:

1

I'm using Eric Czarny's Cocoa XML-RPC framework to make a call to the Wordpress API's. I've downloaded the sample app from Wordpress which gives some good examples. Unfortunately the good examples are for every call EXCEPT wp.newComment.

I'm trying to post a comment using the code below and I keep getting an error with a localized description that tells me to check my input parameters. I've checked and rechecked and I don't understand what is wrong.

Any ideas?

NSDictionary *commentStructure = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber   numberWithInt:0], @"comment_parent", @"xmlrpc anonymous comments plugin now enabled", @"content", @"Test Author", @"author", @"http://iphone.someurl.com", @"author_url", @"[email protected]", @"author_email", nil];

NSArray *args = [NSArray arrayWithObjects:[NSNumber numberWithInt:0], @"", @"", [NSNumber numberWithInt:[self.parentFeedItem.postID intValue]], commentStructure, nil];   // the param(s)
NSString *server = [[[NSString alloc] initWithString:@"http://www.someurl.com/xmlrpc.php"] autorelease];         // the server
NSString *method = [[[NSString alloc] initWithString:@"wp.newComment"] autorelease];                        // the method
XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithHost:[NSURL URLWithString:server]];
[request setMethod:method withObjects:args];
id response = [self executeXMLRPCRequest:request];
[request release];

if( [response isKindOfClass:[NSError class]] ) {
    //return nil;
    NSLog(@"There was a problem");
    NSLog([response localizedDescription]);
}
A: 

I found that I had downloaded an older version of the example Wordpress source code which did not have an example for wp.newComment.

You can find a much newer version of the source code here which does have better examples.

http://iphone.trac.wordpress.org/browser

Using the examples from the newer code I was able to resolve my issues.

radesix