tonybaldwin: tony baldwin (Default)
[personal profile] tonybaldwin
Okay...I've started to hack up the xmlrpc functions.
First, I had to replace all "<" and ">" in html tags in a post with"&lt;" and "&gt;",
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 "&lt;" and "&gt;",
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 05:38 pm (UTC)
catness: (Default)
From: [personal profile] catness
Aren't there any low-level libraries in Tcl which convert array to xml-rpc data? Then you can use it in a more straightforward way, as xml-rpc is supposed to add convenience, not pain in the ass ;) For example, in C++ it goes something like that:

....params is an array (hash).......
params["username"] = username;
params["password"] = password;
....
.......props - another array......
props["current_mood"] = mood;
props["current_music"] = music;
params["props"] = props;
.......
and then just use the function which converts the array to proper xml-rpc data and sends to the server.

(no subject)

Date: 2010-04-06 07:52 pm (UTC)
catness: (Default)
From: [personal profile] catness
Maybe your headers are wrong? make sure it's Content-Type: text/xml, Content-Length is correct, and the url is /interface/xmlrpc.

Yeah, it doesn't make sense to require the user to install a crapload of stuff. (That's why btw I can't stand Python and Ruby applications - on my system, most of them require upgrades and addons which are incompatible with the current versions, and something inevitably breaks)

(no subject)

From: [personal profile] catness - Date: 2010-04-06 08:06 pm (UTC) - Expand

(no subject)

Date: 2010-04-06 08:15 pm (UTC)
catness: (Default)
From: [personal profile] catness
yes, params and props are different. Sorry I skipped over the xml data in your post without verifying if it's correct. here's a properly formed example (dumped my data stream while sending) :
<?xml version="1.0"?>
<methodCall>
<methodName>LJ.XMLRPC.postevent</methodName>
<params>
<param>
<value><struct>
<member>
<name>auth_challenge</name>
<value><string>blablabla</string></value>
</member>
<member>
<name>auth_method</name>
<value><string>challenge</string></value>
</member>
<member>
<name>auth_response</name>
<value><string>blablabla</string></value>
</member>
<member>
<name>day</name>
<value><int>6</int></value>
</member>
<member>
<name>event</name>
<value><base64>aGVsbG8gd29ybGQKLS0tLS0KaGVsbG8KLS0tLS0=</base64></value>
</member>
<member>
<name>hour</name>
<value><int>23</int></value>
</member>
<member>
<name>lineendings</name>
<value><string>unix</string></value>
</member>
<member>
<name>min</name>
<value><int>9</int></value>
</member>
<member>
<name>mode</name>
<value><string>postevent</string></value>
</member>
<member>
<name>mon</name>
<value><int>4</int></value>
</member>
<member>
<name>props</name>
<value><struct>
<member>
<name>current_mood</name>
<value><string>awake</string></value>
</member>
<member>
<name>current_moodid</name>
<value><int>87</int></value>
</member>
<member>
<name>opt_backdated</name>
<value><int>0</int></value>
</member>
<member>
<name>taglist</name>
<value><string>hello, world</string></value>
</member>
<member>
<name>useragent</name>
<value><string>QTXPost/0.3.0</string></value>
</member>
</struct></value>
</member>
<member>
<name>security</name>
<value><string>public</string></value>
</member>
<member>
<name>subject</name>
<value><string>test</string></value>
</member>
<member>
<name>username</name>
<value><string>my_username</string></value>
</member>
<member>
<name>ver</name>
<value><int>1</int></value>
</member>
<member>
<name>year</name>
<value><int>2010</int></value>
</member>
</struct></value>
</param>
</params>
</methodCall>

(no subject)

Date: 2010-04-06 08:37 pm (UTC)
catness: (Default)
From: [personal profile] catness
Never mind auth_challenge, I suppose it should work with plain passwords for a start - but have a look at http://www.livejournal.com/doc/server/ljp.csp.xml-rpc.getchallenge.html (I can explain further if you need)
(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 &gt; and &lt; ;)

The LJ documentation is a bit terse, that's right... but you'll get the hang of it eventually!
(deleted comment)

(no subject)

From: [personal profile] catness - Date: 2010-04-06 08:50 pm (UTC) - Expand

(no subject)

From: [personal profile] catness - Date: 2010-04-06 08:59 pm (UTC) - Expand

(no subject)

From: [personal profile] catness - Date: 2010-04-07 04:57 am (UTC) - Expand

(no subject)

From: [personal profile] catness - Date: 2010-04-07 08:30 am (UTC) - Expand

(no subject)

From: [personal profile] catness - Date: 2010-04-07 02:58 pm (UTC) - Expand

Re: curioser and curioser

Date: 2010-04-07 04:16 pm (UTC)
catness: (Default)
From: [personal profile] catness
No, getchallenge does NOT need username/password (that's why it's secure ;) You can see exactly what it needs:
http://www.livejournal.com/doc/server/ljp.csp.xml-rpc.getchallenge.html

re:base64, cyrillic characters certainly require encoding, not sure about European languages, I think German characters worked without it...

Re: curioser and curioser

Date: 2010-04-07 04:19 pm (UTC)
catness: (Default)
From: [personal profile] catness
Can you print out the full response from the server (before parsing it)?

Re: curioser and curioser

From: [personal profile] catness - Date: 2010-04-07 04:29 pm (UTC) - Expand

Re: curioser and curioser

From: [personal profile] catness - Date: 2010-04-07 04:50 pm (UTC) - Expand

(no subject)

Date: 2010-04-07 05:37 pm (UTC)
catness: (Default)
From: [personal profile] catness
Yay!

Probably you're not creating the response correctly - it's not just sending the challenge back to the server, it's creating an md5 hash with it and password.

(no subject)

Date: 2010-04-07 06:55 pm (UTC)
catness: (Default)
From: [personal profile] catness
Meanwhile, I dunno about the challenge but I've succeeded to post with cleartext password just fine, with the following script (though it's my first attempt on using tcl so I don't really know what I'm doing, lol). You can see the result at http://catness.insanejournal.com/204215.html
(the server returns the url among the result data)

#!/usr/bin/tclsh

package require http;

set url "http://www.insanejournal.com/interface/xmlrpc"

set password "MYPASSWORD"
set username "catness"

set post "<?xml version=\"1.0\"?>
<methodCall>
<methodName>LJ.XMLRPC.postevent</methodName>
<params>
<param>
<value><struct>
<member>
<name>day</name>
<value><int>7</int></value>
</member>
<member>
<name>event</name>
<value><string>This is a test. Please ignore.</string></value>
</member>
<member>
<name>hour</name>
<value><int>21</int></value>
</member>
<member>
<name>lineendings</name>
<value><string>unix</string></value>
</member>
<member>
<name>min</name>
<value><int>40</int></value>
</member>
<member>
<name>mon</name>
<value><int>4</int></value>
</member>
<member>
<name>props</name>
<value><struct>
<member>
<name>current_mood</name>
<value><string>awake</string></value>
</member>
<member>
<name>current_moodid</name>
<value><int>87</int></value>
</member>
<member>
<name>taglist</name>
<value><string>test</string></value>
</member>
<member>
<name>useragent</name>
<value><string>tcl</string></value>
</member>
</struct></value>
</member>
<member>
<name>security</name>
<value><string>public</string></value>
</member>
<member>
<name>subject</name>
<value><string>test, please ignore</string></value>
</member>
<member>
<name>username</name>
<value><string>$username</string></value>
</member>
<member>
<name>password</name>
<value><string>$password</string></value>
</member>
<member>
<name>ver</name>
<value><int>1</int></value>
</member>
<member>
<name>year</name>
<value><int>2010</int></value>
</member>
</struct></value>
</param>
</params>
</methodCall>"

puts $post

puts $url

set post_response [http::geturl $url -query $post -type "text/xml" ]

puts [http::data $post_response]

(no subject)

Date: 2010-04-07 08:26 pm (UTC)
catness: (Default)
From: [personal profile] catness
And I fixed the challenge too (got curious - damn you ;) Here's the code which creates $response from $challenge and $password - note the "tolower" bit, cost me a couple of hours, doesn't work without it... all the rest is the same as in the previous example, except for using auth_challenge and auth_response, of course. The whole script is too long to post because it's using some xml processing function which I've found elsewhere, but I can send it if you need.

set encoded [string tolower [md5::md5 -hex $password] ]
set cat $challenge$encoded
set response [string tolower [md5::md5 -hex $cat] ]

This post starts to be difficult to navigate... ;)

Re: success, at last!

Date: 2010-04-10 05:01 am (UTC)
catness: (Default)
From: [personal profile] catness
Wh00t!!!! :D :D

I suggest you should add challenge/response at some stage - sending password in clear text over an unencrypted connection makes a lot of people twitchy.

Also if you want more LJ-clones for testing, I've been using http://www.inksome.com and http://www.scribbld.net/ . (I used to have DJ but deleted it; as far as I remember, it did work with XML-RPC)

Re: success, at last!

From: [personal profile] catness - Date: 2010-04-10 07:17 am (UTC) - Expand

Re: success, at last!

From: [personal profile] catness - Date: 2010-04-10 09:34 am (UTC) - Expand

Profile

tonybaldwin: tony baldwin (Default)
tonybaldwin

December 2013

S M T W T F S
1234567
8 91011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags