2010-04-16 47 views
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]); 
} 

回答

0

我發現我已經下載了一個較舊版本的示例Wordpress源代碼,它沒有wp.newComment的示例。

你可以在這裏找到一個更新的源代碼版本,它有更好的例子。

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

從較新的代碼,我能解決我的問題,使用的例子。