【问题标题】:Wordpress XML-RPC call from Objective C: wp.newComment来自 Objective C 的 Wordpress XML-RPC 调用:wp.newComment
【发布时间】:2010-04-16 13:48:24
【问题描述】:

我正在使用 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", @"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]);
}

【问题讨论】:

    标签: iphone wordpress xml-rpc


    【解决方案1】:

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

    您可以在此处找到更新版本的源代码,其中包含更好的示例。

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

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

    【讨论】:

      猜你喜欢
      • 2012-11-26
      • 1970-01-01
      • 2011-05-21
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      • 2011-09-23
      • 1970-01-01
      • 2013-09-22
      相关资源
      最近更新 更多