Log in

No account? Create an account
A post in my journal with Perl. - LiveJournal Client Discussions — LiveJournal [entries|archive|friends|userinfo]
LiveJournal Client Discussions

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

A post in my journal with Perl. [Oct. 17th, 2004|09:24 pm]
LiveJournal Client Discussions


I'm trying to write something simple in Perl, to post a private message in my journal.
Is not working for me, though.

This is what I have done so far:

#!/usr/bin/perl -w
use IO::Socket::INET;
$MySocket=new IO::Socket::INET->new(

$msg="POST /interface/flat HTTP/1.0
Host: www.livejournal.com
Content-type: application/x-www-form-urlencoded

I tried just telnet www.livejournal.com and pasting $msg, and the connection gets' closed.
Am I missing something?
Also, how would you implement this, so that the password is not sent in clear text?.

I read http://www.livejournal.com/doc/server/ljp.csp.flat.postevent.html but says that password is Deprecated?
I'm confused.

Perhaps one of you can give me an example on what to put on that line that starts with "mode"


[User Picture]From: vanbeast
2004-10-18 12:13 pm (UTC)
Actually, on that topic, I can't seem to find any url-encoding functions/modules anywhere, and neither can anyone here. We're probably just being dumb... do you know where I can find those?
(Reply) (Parent) (Thread)
(Deleted comment)
[User Picture]From: bleything
2004-10-18 12:18 pm (UTC)
Doesn't do URL encoding, just entitizing... at least as far as the CPAN page says.
(Reply) (Parent) (Thread)
[User Picture]From: lordindra
2004-10-18 12:20 pm (UTC)
URI::Escape includes the functions uri_escape and uri_unescape which will do that for you. Its part of the URI::URL module collection from CPAN includes this.

Page 21 of CGI Programming With Perl has the code for two functions that do the same thing, though it recommends using the ones from the module.
(Reply) (Parent) (Thread)
[User Picture]From: vanbeast
2004-10-18 12:21 pm (UTC)
Rad, that's what I was looking for. I knew I had seen it before, but just couldn't track it down.

Kinda painful to bring in two modules for a 10-line hack, though ;)
(Reply) (Parent) (Thread)
[User Picture]From: lordindra
2004-10-18 12:25 pm (UTC)
You only need to bring in URI::Escape. Its just that that module is part of the collection called URI::URL. Granted, you have to install the whole collection unless you want to go through some hoops, but you only have to bring in the one to your actual script to do the escaping/unescaping.
(Reply) (Parent) (Thread)
[User Picture]From: vanbeast
2004-10-18 12:32 pm (UTC)
Oh right, what I meant was URI::Escape and LWP :)
(Reply) (Parent) (Thread)