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-07 08:26 pm (UTC)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... ;)
success, at last!
Date: 2010-04-10 01:45 am (UTC)I DID IT!!!
FINALLY!!!
Re: success, at last!
Date: 2010-04-10 02:17 am (UTC)################
# post to livejournal...
proc ljpost {} {
# changing html tags for insertion in xml
set content [.txt.txt get 1.0 end]
set escaped [string map {
"<" "<"
">" ">"
\" "\""
} $content]
.txt.txt delete 1.0 end
.txt.txt insert insert $escaped
# is it redundant that ptext and escaped from the above are the same?
# probably
set ptext [.txt.txt get 1.0 {end -1c}]
global mypost
set mypost "<?xml version=\"1.0\"?>
<methodCall><methodName>LJ.XMLRPC.postevent</methodName>
<params><param>
<value><struct>
<member><name>year</name><value><int>$::year</int></value></member>
<member><name>mon</name><value><int>$::mon</int></value></member>
<member><name>day</name><value><int>$::day</int></value></member>
<member><name>hour</name><value><int>$::hour</int></value></member>
<member><name>min</name><value><int>$::min</int></value></member>
<member><name>usejournal</name><value><string>$::usej</string></value></member>
<member><name>event</name><value><string>$ptext</string></value></member>
<member><name>username</name><value><string>$::ljname</string></value></member>
<member><name>password</name><value><string>$::ljpswd</string></value></member>
<member><name>subject</name><value><string>$::subject</string></value></member>
<member><name>lineendings</name><value><string>unix</string></value></member>
<member><name>security</name><value><string>$::priv</string></value></member>
<member><name>ver</name><value><int>1</int></value></member>
<member><name>props</name>
<value><struct>
<member><name>useragent</name><value><string>Xpostulate</string></value></member>
<member><name>current_location</name><value><string>$::loc</string></value></member>
<member><name>current_mood</name><value><string>$::mood</string></value></member>
<member><name>taglist</name><value><string>$::tags</string></value></member>
<member><name>current_music</name><value><string>$::tunes</string></value></member>
</struct></value></member>
</struct></value>
</param></params>
</methodCall>"
global plength
set plength [string length $mypost]
set dopost [http::geturl http://www.livejournal.com/interface/xmlrpc -query $::mypost -type "text/xml" ]
set ljmta [http::meta $dopost]
set ljstat [http::status $dopost]
set ljresponse [http::data $dopost]
# upvar #0 $dopost state
# puts $state(body)
toplevel .rsp
wm title .rsp "Post Status"
frame .rsp.btns
grid [tk::label .rsp.btns.lbl -text "Frank says: $ljstat\nPost length: $::plength"]
grid [tk::button .rsp.btns.view -text "View Journal" -command {
set ljv "http://$::usej.livejournal.com"
exec $::brow $ljv &
}]\
[tk::button .rsp.btns.ok -text "DONE" -command {destroy .rsp}]
frame .rsp.txt
text .rsp.txt.t -width 80 -height 20
.rsp.txt.t insert end $ljresponse
pack .rsp.btns -in .rsp -side top -fill x
pack .rsp.txt.t -in .rsp.txt -side top -fill x
pack .rsp.txt -in .rsp -side top -fill x
}
It seems to be working on LJ, IJ, and DW.
Iziblog apparently doesn't play with xmlrpc (but flatposting works fine there), and, I don't have a deadjournal to test that.
Now, I just have to look at the difference between lj.xmlrpc and wordpress, and I'll have wordpress posting working!
The google api for blogger can't be too far a stretch, either...
Re: success, at last!
Date: 2010-04-10 05:01 am (UTC)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!
Date: 2010-04-10 06:30 am (UTC)I'll have to look at how you generated the md5 hash again.
I should have bookmarked that, but I've got the e-mail notification that will point me there still in my gmail inbox.
I have also just now succeeded in posting to WordPress using metaWeblog.newpost.
The only issue I have now is, I'm change the < in the post the first time it is sent, and all &, so, when the user crossposts to another xmlrpc using server, < becomes &lt;
I have to somehow make each posting proc test to see if that's been done already, like, have it throw a switch the first time
(set tagsconverted "1"), then test that before converting them in further posts (if $tagconvert != 1, then proceed with conversion).
Or set tagscon 0 at initation, then set tagscon 1 when converted,
and, if tagscon = 0, proceed with conversion, otherwise not...or something.
That will take all over 10 mins to implement, but it's 2:30 am and I'm tired...
Also, oddly, the wp interface allows setting the category, but not adding tags...not that there's anything I can do about that, but I find that odd, and don't like it (you have to go to wordpress and add the tags after, which is just silly).
But, anyway, Xpostulate can now (at least from here) post to LJ, DW, DJ and IJ with xmlrpc, and post to WP.
I might remove support for Iziblog.net...I dunno.
And, perhaps I should add inksome and scribbld...didn't know about those.
And, shortly I will add blogger.
But I haven't released anything with any of the xmlrpc stuff, just yet, since I need to fix the tag conversion.
Re: success, at last!
Date: 2010-04-10 07:05 am (UTC)I just signed up at scribbld (http://www.scribbld.net/users/tonybaldwin/).
I received the same response from scribbld as I did from iziblog when I tried to post with xmlrpc (server says: eof).
So, I have made both scribbld and iziblog continue to use flatposting in xpostulate, but, yes, just added scribbld.
I was just thinking...if I don't replace the <brackets in the text widget, but only convert them for setting the variable, then it won't matter if that is redone each time something is posted. You know, convert the tags in the background, not in the interface.
Re: success, at last!
Date: 2010-04-10 07:17 am (UTC)Hmm, both of them work fine for me with xml-rpc. I guess you're still missing some small detail.
Re: success, at last!
Date: 2010-04-10 09:34 am (UTC)Re: success, at last!
Date: 2010-04-10 04:20 pm (UTC)I've only posted to inksome, so far, with flatpost.
I'll see about fixing ink and scrib later...probably just need to take another minute detailed look at the process again, might have altered something somewhere inadvertently...
oddly, I released with izi, ink and scrib all on flat posting, still, with everything else using xmlrpc (which means the user has to be careful about thei r html tags...but I have implemented a conversion in both directions at the flick of a menu item).
I've got the wordpress working, but can't post to my own wordpress installation without disabling my spam protection (bad behavior plugin), oddly.
Bad Behavior blocks tcl http requests...
I'm in communication with the bad behavior folks.
Doesn't make sense to block a whole language.
I'm sure they're not blocking python urllib request, php, perl, cURL, etc.
Re: success, at last!
Date: 2010-04-10 04:15 pm (UTC)Hey, I can't find you on inksome.
Apparently you're not catness over there...