来自 Objective C 的 WordPress XML-RPC 调用:wp.newComment

发布于 2024-08-29 07:35:21 字数 1486 浏览 6 评论 0原文

我正在使用 Eric Czarny 的 Cocoa XML-RPC 框架来调用 Wordpress API。我已经从 Wordpress 下载了示例应用程序,其中提供了一些很好的示例。不幸的是,除了 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]);
}

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]);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵性 2024-09-05 07:35:21

我发现我下载了旧版本的示例 Wordpress 源代码,其中没有 wp.newComment 的示例。

您可以在这里找到源代码的更新版本,其中确实有更好的示例。

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

使用较新代码中的示例我能够解决我的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文