xmlrpc posting with Xpostulate
Apr. 6th, 2010 10:46 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Okay...I've started to hack up the xmlrpc functions.
First, I had to replace all "<" and ">" in html tags in a post with"<" and ">",
and then, I have basically just handwritten out a relevant xml file.
Which looks like this:
<?xml version="1.0"?><methodCall><methodName>LJ.XMLRPC.postevent</methodName><params><param><value><struct><member><name>username</name><value><string>tonytraductor</string></value></member><member><name>password</name><value><string>XXXXXXXX</string></value></member><member><name>subject</name><value><string>xmlrpc posting</string></value></member><member><name>lineendings</name><value><string>pc</string><value></member><member><name>year</name><value><int>2010</int></value></member><member><name>mon</name><value><int>04</int></value></member><member><name>day</name><value><int>06</int></value></member><member><name>hour</name><value><int>10</int></value></member><member><name>min</name><value><int>46</int></value></member><member><name>prop_current_location</name><value><string>127.0.0.1</string></value></member><member><name>propr_current_mood</name><value><string>focused</string></value></member><member><name>prop_taglist</name><value><string>xmlrpc, xpostulate, wordpress, livejournal, dreamwidth, insanejournal</string></value></member><member><name>prop_currentmusic</name><value><string>none</string></value></member><member><name>userjournal</name><value><string>which journal?</string></value></member><member><name>event</name><value><string>Okay...I've started to hack up the xmlrpc functions.
First, I had to replace all "<" and ">" in html tags in a post with "<" and ">",
and then, I have basically just handwritten out a relevant xml file.
</string></value></member></struct></value></param></params></methodCall>
What I haven't done is tried to send such a file to a server, yet...
I'm not sure if the posting method has to be different from a flat post, in terms of simply sending this file as the post data...
More work...
But, hey, I'm working on it!
First, I had to replace all "<" and ">" in html tags in a post with"<" and ">",
and then, I have basically just handwritten out a relevant xml file.
Which looks like this:
<?xml version="1.0"?><methodCall><methodName>LJ.XMLRPC.postevent</methodName><params><param><value><struct><member><name>username</name><value><string>tonytraductor</string></value></member><member><name>password</name><value><string>XXXXXXXX</string></value></member><member><name>subject</name><value><string>xmlrpc posting</string></value></member><member><name>lineendings</name><value><string>pc</string><value></member><member><name>year</name><value><int>2010</int></value></member><member><name>mon</name><value><int>04</int></value></member><member><name>day</name><value><int>06</int></value></member><member><name>hour</name><value><int>10</int></value></member><member><name>min</name><value><int>46</int></value></member><member><name>prop_current_location</name><value><string>127.0.0.1</string></value></member><member><name>propr_current_mood</name><value><string>focused</string></value></member><member><name>prop_taglist</name><value><string>xmlrpc, xpostulate, wordpress, livejournal, dreamwidth, insanejournal</string></value></member><member><name>prop_currentmusic</name><value><string>none</string></value></member><member><name>userjournal</name><value><string>which journal?</string></value></member><member><name>event</name><value><string>Okay...I've started to hack up the xmlrpc functions.
First, I had to replace all "<" and ">" in html tags in a post with "<" and ">",
and then, I have basically just handwritten out a relevant xml file.
</string></value></member></struct></value></param></params></methodCall>
What I haven't done is tried to send such a file to a server, yet...
I'm not sure if the posting method has to be different from a flat post, in terms of simply sending this file as the post data...
More work...
But, hey, I'm working on it!
(no subject)
Date: 2010-04-06 08:30 pm (UTC)I hate that.
How'd you post with the < in there?
I seem to be missing some stuff, too.
(auth_challenge, auth_method, auth_respons...don't know what needs to be in there (sure it's not "blablabla", too), haven't seen it)
So, clearly, I have some more learning to do, but, the thing is, the documentation I have found is woefully inadequate in explaining this things...at least for a rather novice programmer, such as myself.
(no subject)
Date: 2010-04-06 08:37 pm (UTC)(and I've replaced the real data with blablabla just in case, for security - the challenge is supposed to expire after posting, but I'm a bit paranoid)
Also, probably you don't have to base64-encode the post content, unless you post in non-English languages with weird characters.
For using angle brackets, replace them with > and < ;)
The LJ documentation is a bit terse, that's right... but you'll get the hang of it eventually!
(no subject)
Date: 2010-04-06 08:44 pm (UTC)I just mean posting with the tags intact, without using [ and ]
.
like this
<a href="http://baldwinsoftware.com/xpost.html">here's a link to Xpostulate</a>
(no subject)
Date: 2010-04-06 08:50 pm (UTC)(no subject)
Date: 2010-04-06 08:59 pm (UTC)(no subject)
Date: 2010-04-06 09:31 pm (UTC)I have to request some key?
Then I have to parse some xml file to retrieve the key, so I can send it with my post?
That's excessively complicated...and seems needlessly so, to me.
That's going to be a real headache, extracting the key from the xml response from the server.
Why do they have to complicate everything in this manner?
Flat posting works great, and is so simple.
But every other blog service (blogger, wordpress) requires some form of xmlrpc or derivative thereof.
I don't understand the popularity of this obfuscation.
I thought hackers were supposed to seek to simplify things, not make them more difficult.
(no subject)
Date: 2010-04-07 04:57 am (UTC)You're just a bit unlucky that you're using a non-mainstream language which doesn't have a good xml-rpc implementation yet. Even then, you can write that yourself, and then use it for all the other sites (e.g. wordpress) in exactly the same way (and other Tcl users probably will appreciate it too! the problem is solved once and for all.) While with flat interface, the programmer has to write a new parser for each protocol because there are no standards.
The purpose of challenge/response method is security; when you send password in cleartext, everyone can snoop on your traffic and get access to your account, especially with wireless (and from what I'm reading on Bash, people actually do it). I suggest that for now you get xml-rpc working without it. I'll explain challenge/response later, when I'll be more awake. And here's a better reference, with an example in Perl: http://www.livejournal.com/doc/server/ljp.csp.auth.challresp.html which also shows the simplicity of using XML-RPC interface.
(no subject)
Date: 2010-04-07 08:30 am (UTC)(no subject)
Date: 2010-04-07 02:37 pm (UTC)Client error: Missing required argument(s)
back from the server.
It must be the getchallenge thing, which I haven't implemented, unless there's something else I'm blindly leaving out.
According to the LJ docs I can find for postevent, it seems I have all required arguments (and the getchallenge stuff is NOT mentioned in the LJ docs I can find for postevent)
Here's my xml:
<?xml version="1.0"?>
<methodCall><methodName>LJ.XMLRPC.postevent</methodName>
<params><param><value><struct>
<member><name>username</name><value><string>someclown</string></value></member>
<member><name>password</name><value><string>yomamaisfat</string></value></member>
<member><name>subject</name><value><string>test post</string></value></member>
<member><name>lineendings</name><value><string>pc</string></value></member>
<member><name>year</name><value><int>2010</int></value></member>
<member><name>mon</name><value><int>04</int></value></member>
<member><name>day</name><value><int>07</int></value></member>
<member><name>hour</name><value><int>10</int></value></member>
<member><name>min</name><value><int>31</int></value></member>
<member><name>userjournal</name><value><string>tonytraductor</string></value></member>
<member><name>event</name><value><string><base64>some text</base64></string></value></member>
<member><name>props</name>
<value><struct>
<member><name>useragent</name><value><string>Xpostulate</string></value></member>
<member><name>prop_current_location</name><value><string>127.0.0.1</string></value></member>
<member><name>prop_current_mood</name><value><string>mood</string></value></member>
<member><name>prop_taglist</name><value><string>test post</string></value></member>
<member><name>prop_currentmusic</name><value><string>music</string></value></member>
</struct></value></member>
</struct></value>
</param></params>
</methodCall>
sending it (apparently successfully), with set dopost [http::geturl http://www.livejournal.com/interface/xmlrpc -query $::pxml -type "text/xml" ]
(no subject)
Date: 2010-04-07 02:38 pm (UTC)I'm going to second guess that, and add them back in...brb
(no subject)
Date: 2010-04-07 02:45 pm (UTC)syntax error at line 1, column 0, byte 0 at /usr/lib/perl5/XML/Parser.pm line 187", when I add the following headers back in:
Considering that line 1 column 0 would be "P" in "POST", I'm assuming that the headers were decidedly NOT the missing argument.
I'm going to have to get the getchallenge auth thing working...
aaarghh...
(no subject)
Date: 2010-04-07 02:58 pm (UTC)- it's usejournal, not userjournal (anyway it can be omitted if you post in your own journal)
- the prop names must not have "prop_" prepended to it, i.e. it is: current_location, current_mood, taglist and current_music (see http://www.livejournal.com/doc/server/ljp.csp.proplist.html - it is different from flat interface)
- event: it's either "string" or "base64" but not both - if you do not encode it to base64, remove base64 tag, otherwise remove string tag (I'm not sure about this, but this is what I see in my data stream) - maybe that's the problem, event is a required field
Maybe you have to specify auth_method=clear, even though it's supposed to be default.
(no subject)
Date: 2010-04-07 04:09 pm (UTC)I've correct the props, etc.
At this point, I think I mostly need to get the challenge sorted out.
The data I'm feeding my parser (which should be the server response) when asking for the challenge seems to be incorrect.
This is how I'm trying to get that:
http://pastebin.com/ed4cTjaG
to set the
value for $mychal in
<member><name>challenge</name><value><string>$mychal</string></value></member>
(no subject)
Date: 2010-04-07 04:11 pm (UTC)They are regular utf8 chars, so, likely not?
base64 should only be required for asian/arabic/cyrillic or such?