<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title></title>
</head>
<body>
<p style="margin: 0px;">OK, now I understand what you're doing.</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">When I first started working with WordPress and XMLRPC, I tried building my own library ... it was taking a long time, and I ran into many of the issues you're running in to now.  Someone suggested I use the built-in IXR library instead, and it made all the difference.</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">Here's a simple example:</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">include_once(ABSPATH . WPINC . '/class-IXR.php');</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">$client = new IXR_Client('destinantion_url');</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">$client->query('procedure.name', 'arg1', 'arg2', 'arg3', ...);</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">$response = $client->getResponse();</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">That will load the library, create a new client pointing at whatever WP installation you're working with, execute your remote procedure, and store the response (errors, data, or whatever) in the $response variable.</p>
<p style="margin: 0px;"> </p>
<p> </p>
<div style="margin: 5px 0px 5px 0px; font-family: monospace;">
On June 15, 2010 at 6:51 PM Tim Golen <tim@golen.net> wrote:<br />
<br />
> Hi Joseph,<br />
><br />
> Right on, that's exactly what I needed to know.<br />
><br />
> I've been using http://devzone.zend.com/article/1307 for the XML-RPC (lower<br />
> level) API, and then building my own PHP library on top of that (with the<br />
> Wordpress functions). I'll go and check out the IXR library to see if that<br />
> helps.<br />
><br />
> All of the calls that I am making that pull data from Wordpress are working<br />
> fine. It's just when trying to create data (wp.newComment, wp.newCategory,<br />
> metaWeblog.newPost) they are all giving me similar data errors:<br />
><br />
> Sorry, the new category failed.<br />
><br />
> Invalid Data: Please go back and try again.<br />
><br />
> Content, title, and excerpt are empty.<br />
><br />
> I've been debugging the thing to death and still can't get any closer. I<br />
> have a feeling that it has something to do with how the struct datatypes are<br />
> being encoded in the XML-RPC portion. Here is a sample of my code:<br />
><br />
><br />
> $this->makeRequest(<br />
> 'wp.newComment',<br />
> array(<br />
> new xmlrpcval($blogId),<br />
> new xmlrpcval($this->username),<br />
> new xmlrpcval($this->password),<br />
> new xmlrpcval($postId),<br />
> xmlrpc_encode(array(<br />
> 'comment_parent'=>intval(0),<br />
> 'content'=>strval($comment->content),<br />
> 'author'=>strval($comment->author),<br />
> 'author_url'=>strval($comment->author_url),<br />
> 'author_email'=>strval($comment->author_email)<br />
> )),<br />
> ));<br />
><br />
> The structure containing the comment information ends up being encoded to<br />
> this:<br />
><br />
> <params><br />
> <param><br />
>  <value><br />
>   <struct><br />
>    <member><br />
>     <name>comment_parent</name><br />
>     <value><br />
>      <int>0</int><br />
><br />
>     </value><br />
>    </member><br />
>    <member><br />
>     <name>content</name><br />
>     <value><br />
>      <string>comment</string><br />
>     </value><br />
>    </member><br />
><br />
>    <member><br />
>     <name>author</name><br />
>     <value><br />
>      <string>Tim</string><br />
>     </value><br />
>    </member><br />
>    <member><br />
>     <name>author_url</name><br />
><br />
>     <value><br />
>      <string>http://www.golen.net/blog</string><br />
>     </value><br />
>    </member><br />
>    <member><br />
>     <name>author_email</name><br />
>     <value><br />
>      <string>tim@golen.net</string><br />
><br />
>     </value><br />
>    </member><br />
>   </struct><br />
>  </value><br />
> </param><br />
> </params><br />
><br />
><br />
> And all that is encoded the way they discuss it at<br />
> http://devzone.zend.com/article/1307. I'll take a look at the IXR library<br />
> and see if that does any better of a job. I appreciate all of your help and<br />
> suggestions with this! Once I get the PHP library built, I think it would be<br />
> an invaluable resource to post on the Wordpress site somewhere.<br />
><br />
> Tim<br />
><br />
> On Tue, Jun 15, 2010 at 12:37 PM, Joseph Scott <joseph@josephscott.org>wrote:<br />
><br />
> > There are 2 different "levels" of libraries for the the WP XML-RPC<br />
> > APIs.  First, lower level XML-RPC only APIs.  These take care of all<br />
> > the XML-RPC work, but don't know anything about the specific methods<br />
> > that WordPress provides.  For that layer I recommend the PHP IXR<br />
> > library, which is what WordPress uses.<br />
> ><br />
> > The next level up are libraries both take care of the XML-RPC details<br />
> > and know about the various methods that WP exposes.  I've seen some<br />
> > Perl libraries that fit into this category, but I haven't seen much in<br />
> > the of PHP ones.<br />
> ><br />
> > On Tue, Jun 15, 2010 at 11:51 AM, Tim Golen <tim@golen.net> wrote:<br />
> > > Is there already an existing PHP library for the Wordpress API? I'm still<br />
> > > running into problems and don't need to reinvent the wheel if it's<br />
> > already<br />
> > > been done. The MetaWeblog API mentions a PHP library, but it comes up<br />
> > with a<br />
> > > 404 error, and the MetaWeblog site hasn't been updated since 2003.<br />
> > > Errors like "Invalid Data: Please go back and try again." when trying to<br />
> > do<br />
> > > something rather simple like create a comment can get really frustrating.<br />
> ><br />
> ><br />
> ><br />
> > --<br />
> > Joseph Scott<br />
> > joseph@josephscott.org<br />
> > http://josephscott.org/<br />
> > _______________________________________________<br />
> > wp-xmlrpc mailing list<br />
> > wp-xmlrpc@lists.automattic.com<br />
> > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc<br />
> ><br />
</div>
</body>
</html>