0
我正在使用Eric Czarny的Cocoa XML-RPC框架來調用Wordpress API。我從Wordpress下載了示例應用程序,它提供了一些很好的示例。不幸的是,除了wp.newComment之外,每個調用都有很好的例子。來自Objective C的Wordpress XML-RPC調用:wp.newComment
我正在嘗試使用下面的代碼發表評論,並且我不斷收到一條本地化描述的錯誤消息,告訴我要檢查我的輸入參數。我已檢查並重新檢查,我不明白什麼是錯的。
任何想法?
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]);
}