Post XMLRPC using Rflatten.pm

As prommised a test script with Rflatten.pm for you to play with. I have created three test POST forms:

  • Livejournal
  • Broerse Blog
  • Ping-O-Matic
  • Of course you can’t test the Broerse Blog form but you can create a Livejournal blog and play with the Livejournal form. The Ping-O-Matic form just works. You can also ping your own Blog with it. I also tried Blogger but Google closed down the http://plant.blogger.com/api/RPC2 XMLRPC proxy. (Perhaps XML-RPC will die in 2008 by the hand of REST) To explain how you can create complex XML-RPC structures with the Rflatten style of writing see this html source:

    <FORM ACTION=“postxmlrpc.cgi” METHOD=“POST”>
    <INPUT TYPE=HIDDEN NAME=“:0” VALUE=“LJ.XMLRPC.postevent”>
    <INPUT TYPE=HIDDEN NAME=“_proxyurl” VALUE=“http://www.livejournal.com/interface/xmlrpc”>

    <TABLE BORDER=0>
    <TR><TD>username</TD><TD><INPUT TYPE=TEXT NAME=“:1.username” VALUE=“” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>password</TD><TD><INPUT TYPE=PASSWORD NAME=“:1.password” VALUE=“” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>subject</TD><TD><INPUT TYPE=TEXT NAME=“:1.subject” VALUE=“this is the subject” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>event</TD><TD><INPUT TYPE=TEXT NAME=“:1.event” VALUE=“and this is the body.” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>lineendings</TD><TD><INPUT TYPE=TEXT NAME=“:1.lineendings” VALUE=“pc” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>year</TD><TD><INPUT TYPE=TEXT NAME=“:1.year” VALUE=“2008” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>mon</TD><TD><INPUT TYPE=TEXT NAME=“:1.mon” VALUE=“2” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>day</TD><TD><INPUT TYPE=TEXT NAME=“:1.day” VALUE=“3” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>hour</TD><TD><INPUT TYPE=TEXT NAME=“:1.hour” VALUE=“20” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>min</TD><TD><INPUT TYPE=TEXT NAME=“:1.min” VALUE=“45” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD> <BR></TD></TR>
    <TR><TD COLSPAN=2><INPUT TYPE=SUBMIT VALUE=“Post”> <INPUT TYPE=RESET VALUE=“Reset”></TD></TR>
    </TABLE>

    </FORM>

    XMLRPC::Lite uses an Array to generate a XML-RPC call. “:0” is the first item in the Array and always contains the “methodName”. In this example this is “LJ.XMLRPC.postevent”. “_proxyurl” is an exception hard-coded in “postxmlrpc.cgi” to specify the proxyurl for XMLRPC::Lite. Sometimes this is also called the XML-RPC endpoint. Its value will not be included in the XML-RPC data! As you can see here Livejournal uses an XML-RPC struct you specify in the POST with a Hash “:1.” resulting in multiple Hash keys is Array value 1 (“:1”). If you understand this simple call take a look at the following example:

    <FORM ACTION=“postxmlrpc.cgi” METHOD=“POST”>
    <INPUT TYPE=HIDDEN NAME=“:0” VALUE=“metaWeblog.newPost”>
    <INPUT TYPE=HIDDEN NAME=“_proxyurl” VALUE=“http://www.broerse.net/wordpress/xmlrpc.php”>

    <TABLE BORDER=0>
    <TR><TD>blogid</TD><TD><INPUT TYPE=TEXT NAME=“:1” VALUE=“1” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>username</TD><TD><INPUT TYPE=TEXT NAME=“:2” VALUE=“” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>password</TD><TD><INPUT TYPE=PASSWORD NAME=“:3” VALUE=“” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>title</TD><TD><INPUT TYPE=TEXT NAME=“:4.title” VALUE=“this is the title” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>description</TD><TD><INPUT TYPE=TEXT NAME=“:4.description” VALUE=“and this is the body.” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>mt_allow_comments</TD><TD><SELECT NAME=“:4.mt_allow_comments”><OPTION VALUE=“0”>No<OPTION VALUE=“1” SELECTED>Yes</SELECT></TD></TR>
    <TR><TD>mt_allow_pings</TD><TD><SELECT NAME=“:4.mt_allow_pings”><OPTION VALUE=“0”>No<OPTION VALUE=“1” SELECTED>Yes</SELECT></TD></TR>
    <TR><TD>mt_keywords</TD><TD><INPUT TYPE=TEXT NAME=“:4.mt_keywords” VALUE=“xmlrpc, muis” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>categories:0</TD><TD><INPUT TYPE=TEXT NAME=“:4.categories:0” VALUE=“Perl” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>categories:1</TD><TD><INPUT TYPE=TEXT NAME=“:4.categories:1” VALUE=“Web Development” SIZE=25 MAXLENGTH=50></TD></TR>
    <TR><TD>publish</TD><TD><SELECT NAME=“:5”><OPTION VALUE=“0”>No<OPTION VALUE=“1” SELECTED>Yes</SELECT></TD></TR>
    <TR><TD> <BR></TD></TR>
    <TR><TD COLSPAN=2><INPUT TYPE=SUBMIT VALUE=“Post”> <INPUT TYPE=RESET VALUE=“Reset”></TD></TR>
    </TABLE>

    </FORM>

    You see the “:0” again but now you see multiple Array values. Some Array values contain a Hash as in the first example. This Hash in case of the Key “categories” contains an Array with the categories used like this “:4.categories:0” and “:4.categories:1”. See this post to learn more about categories.
    I hope this explains how postxmlrpc.cgi and Rflatten.pm work. I think you must be able to create any XML-RPC call with it. If you like to try it please mail me your proxyurl and server so I can unblock you. Because this is such an universal script I baked some protection, against misuse, in it.


    Comments

    Comments are closed.