开发者

Wordpress XML-RPC call from Objective C: wp.newComment

开发者 https://www.devze.com 2022-12-26 21:45 出处:网络
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 a

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 dictionaryWithObjectsAnd开发者_C百科Keys:[NSNumber   numberWithInt:0], @"comment_parent", @"xmlrpc anonymous comments plugin now enabled", @"content", @"Test Author", @"author", @"http://iphone.someurl.com", @"author_url", @"someemailaddy@hotmail.com", @"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]);
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消