?

Log in

No account? Create an account
May be of interest to those who use moblog like sites, and syndicate… - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Jun. 9th, 2004|11:31 pm]
LiveJournal Client Discussions

lj_clients

[stevenothing]
May be of interest to those who use moblog like sites, and syndicate them to LJ via rss. I’ve written a script that will skip the middleman, and just post the thing directly to LJ, placing the image in a convenient web server nearby, and posting an img tag to that image to LJ. Also good if you don't trust, or want to have to trust the third party, as I've heard unpleasant things about some of them, most notably textamerica.

Anyway...

If anyone is interested, they can check out the code, and constructive criticism is welcomed.

It’s currently running on my home machine, but I’ve restricted it to just my username right now. If anyone wants their name added to have a play about with, let me know. I’ll hopefully be sticking it on a slightly better connected machine tomorrow.

It works kinda similarly to the post to LJ by email system, except you give it your password instead of a pin number. I could have taken the pin number and just used the existing lj to email gateway, but I wanted to get confirmation if the post had succeeded or not, so I could delete the uploaded image if needs be.

The username and password are passed in the subject. Current separator is an !, as that’s quite easy to type on a phone, but this can be changed easily. Format is:

username!password!subject.

Needless to say, the username and password bit will be removed from the subject before posting. Also the password is not stored anywhere on the machine.

You can specify a few parameters as the first thing in your mail, to set various values. If you want to post friends only, for example, you can do

lj-security friends
other possible values are public, private, or the name of one of your custom groups.

Other things you can set, are lj-mood, lj-music and lj-userpic (must match your LJ pic keywords exactly at present).
A few extra options are:

lj-comments, which can be set to “off” or “noemail” if you don’t want notifications.
lj-screening which can be set to none, all, anon or friends (which actually screens non-friends; I may change this).
lj-backdate (set to anything if you want this post to be backdated).

It currently only works with gif/jpgs, and base64-encoding (actually it may work with others, depending on what the MIME::Parser module handles, but I’ve not tried it).

Perl modules you’ll need are:

MIME::Parser
MIME::Entity
and
XMLRPC::Lite. I did play about with RPC::XML, which does everything much more correctly (ie, it doesn’t confuse numbers and strings containing numbers) but it was also much more of a pain to use, as it requires everything to be much more explicit. Compare:


my $event = {username => $ljuser,
auth_method => “challenge”,
auth_challenge => $challenge,
auth_response => $response,
clientversion => $ljversion,
ver => 1,
subject => $ljsubject,
event => $ljbody,
year => $ljyear,
mon => $ljmonth,
day => $ljday,
hour => $ljhour,
min => $ljmin};


with:


my %post = (username => RPC::XML::string->new(“stevenothing”),
auth_method => RPC::XML::string->new(“challenge”),
auth_challenge => RPC::XML::string->new($challenge),
auth_response => RPC::XML::string->new($response),
clientversion => RPC::XML::string->new($version),
ver => RPC::XML::int->new(1),
security => RPC::XML::string->new(“usemask”),
allowmask => RPC::XML::int->new(1),

subject => RPC::XML::string->new(“testing”),
event => RPC::XML::string->new(“test test testy test test”),
year => RPC::XML::string->new(“2004”),
mon => RPC::XML::string->new(6),
day => RPC::XML::int->new(6),
hour => RPC::XML::int->new(21),
min => RPC::XML::int->new(55),
props => RPC::XML::struct->new(
current_mood => RPC::XML::string->new(“happy”),
picture_keyword => RPC::XML::string->new(“bald”),
current_moodid => RPC::XML::int->new(5),
current_music => RPC::XML::string->new(“RPC::XML”),
opt_screening => RPC::XML::string->new(“F”)
));


Were writing this in something that was a bit more fussy about types than perl, I might have reconsidered. But as perl is so lax about such things anyway, it seemed a bit superfluous to have strict types for one small part.

It could do with a few modifications. Current TODOs are:


  • Get the date from the Date: header, instead of the system time. This should be fairly straightforward to do.

  • Be a bit more forgiving about typos and things. Currently the icon name has to match exactly, whereas a pattern match might be more appropriate. And if no match is found, making an educated guess as to the best thing to do is probably wise. Say, if no friend group matching the one you specified exists, post it as a private post. Or if that icon doesn’t exist, post using the default icon.


There’s probably more.
Comments? Thoughts? Reactions? Is this thing even any use?
linkReply