<!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;">Tim,</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">I haven't worked specifically with struct datatypes (in reality, most of the time I just build my own procedure on the server I'm working with) ... but the documentation says you can use them.</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">Here's the full documentation for the IXR library if you want to take a crack at it: http://scripts.incutio.com/xmlrpc/manual.php  Just be sure to post your solution here so we can all learn from you :-)</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">~Eric<span></span></p>
<p> </p>
<div style="margin: 5px 0px 5px 0px; font-family: monospace;">
On June 15, 2010 at 7:20 PM Tim Golen <tim@golen.net> wrote:<br />
<br />
> Thanks Eric! How did you handle the areguments with struct datatypes like<br />
> for creating a new category? Do you just pass in a array with key=>val pairs<br />
> or do you have to do special encoding?<br />
><br />
> Tim<br />
><br />
> On Tue, Jun 15, 2010 at 1:06 PM, eric@eamann.com <eric@eamann.com> wrote:<br />
><br />
> >  OK, now I understand what you're doing.<br />
> ><br />
> ><br />
> ><br />
> > When I first started working with WordPress and XMLRPC, I tried building my<br />
> > own library ... it was taking a long time, and I ran into many of the issues<br />
> > you're running in to now.  Someone suggested I use the built-in IXR library<br />
> > instead, and it made all the difference.<br />
> ><br />
> ><br />
> ><br />
> > Here's a simple example:<br />
> ><br />
> ><br />
> ><br />
> > include_once(ABSPATH . WPINC . '/class-IXR.php');<br />
> ><br />
> ><br />
> ><br />
> > $client = new IXR_Client('destinantion_url');<br />
> ><br />
> ><br />
> ><br />
> > $client->query('procedure.name', 'arg1', 'arg2', 'arg3', ...);<br />
> ><br />
> ><br />
> ><br />
> > $response = $client->getResponse();<br />
> ><br />
> ><br />
> ><br />
> > That will load the library, create a new client pointing at whatever WP<br />
> > installation you're working with, execute your remote procedure, and store<br />
> > the response (errors, data, or whatever) in the $response variable.<br />
> ><br />
> ><br />
> ><br />
> ><br />
> >  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<br />
> > (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<br />
> > that<br />
> > > helps.<br />
> > ><br />
> > > All of the calls that I am making that pull data from Wordpress are<br />
> > working<br />
> > > fine. It's just when trying to create data (wp.newComment,<br />
> > 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<br />
> > 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<br />
> > library<br />
> > > and see if that does any better of a job. I appreciate all of your help<br />
> > and<br />
> > > suggestions with this! Once I get the PHP library built, I think it would<br />
> > 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<br />
> > >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<br />
> > 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<br />
> > to<br />
> > > > do<br />
> > > > > something rather simple like create a comment can get really<br />
> > 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 />
> ><br />
> > _______________________________________________<br />
> > wp-xmlrpc mailing list<br />
> > wp-xmlrpc@lists.automattic.com<br />
> > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc<br />
> ><br />
> ><br />
</div>
</body>
</html>