?

Log in

No account? Create an account
Problems with client development - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

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

Problems with client development [Apr. 11th, 2002|09:06 pm]
LiveJournal Client Discussions

lj_clients

[phil99]
I've been trying to develop a personal LJ Client in perl for a wee while now, and have hit a small problem. Best way to explain it is to demonstrate....

Type "post" to post
Type "check" to Check friends:

check

After CreateMessage()
POST /interface/flat HTTP/1.0
Host: www.livejournal.com
User-Agent: Perl-Phil99/0.01
Content-type: application/x-www-form-urlencoded
Content-length: 47

user=phil99&password=**********&mode=checkfriends

errmsg: Client error: No username sent.
success: FAIL


If I run _exactly_ the same code, but with an ampersand in front of the "user=" section, it works fine. I can't understand why. "user" is _always_ the first value listed in my generated URLs, and as such surely shouldn't need an apersand before it?

Thanks for any help or advice,
Phil
linkReply

Comments:
From: delusion_
2002-04-11 01:17 pm (UTC)
I believe you're supposed to put either a ? or a & in front of it. ? if it's the first querystring, & for everything else that isn't.
(Reply) (Thread)
[User Picture]From: phil99
2002-04-11 02:04 pm (UTC)
http://www.livejournal.com/developer/protocol.bml doesn't mention that at all. The example given doesn't show that either...

Though if it works, why fix it, I guess.
(Reply) (Parent) (Thread)
From: opiummmm
2002-04-11 01:24 pm (UTC)
This is kind of a shot in the dark, but what happens when you order it by mode, user and password?
(Reply) (Thread)
[User Picture]From: phil99
2002-04-11 02:07 pm (UTC)
mode=login&client=Perl-Phil99/0.01&user=phil99&password=******

errmsg: Client error: No mode specified.
success: FAIL


Same again - ampersand in front of "mode" gives nomal ligin

[oops, *changes password VERY quickly*]
(Reply) (Parent) (Thread)
From: opiummmm
2002-04-11 02:16 pm (UTC)

Re:

Haha oops :-)
(Reply) (Parent) (Thread)
[User Picture]From: phil99
2002-04-11 03:15 pm (UTC)
It's not very often I blush - that was one of them....
*coughs politely*
*thwaps himself over the head with a slice of fish wrapped around an extraordinarily large gold brick*
(Reply) (Parent) (Thread)
[User Picture]From: credendovides
2002-04-11 01:26 pm (UTC)
Are you doing the correct CR LF combo on all lines, including the blank line between the header and body? (\r\n or \015\013)
(Reply) (Thread)
[User Picture]From: phil99
2002-04-11 02:09 pm (UTC)
Am doing this:
$message =~ s/\n/\r\n/mg;
on entire message to be sent, the line before sending.
(Reply) (Parent) (Thread)
[User Picture]From: credendovides
2002-04-11 03:09 pm (UTC)
That works, I guess. In that case, are you making sure you don't use \r elsewhere?
(Reply) (Parent) (Thread)
[User Picture]From: phil99
2002-04-11 03:14 pm (UTC)
Shouldn't be - at least I haven't coded a '\r' in anywhere.

I think I've just decided the easiest way to deal with it is to leave the preceding ampersand in, and work round it for now... it doesn't seem to cause any ill effects that I can see.
(Reply) (Parent) (Thread)
[User Picture]From: stesla
2002-04-11 03:16 pm (UTC)
Don't quote me on this, but I don't think you're suposed to use \r\n in the body of the request...just in the headers. That's what I do. I just put the CR-LF after each header, then I only use LF from there on out. If you're curious, you can check the code in the CVS section of my project.
(Reply) (Parent) (Thread)
[User Picture]From: phil99
2002-04-11 03:28 pm (UTC)
hmmmm, you can use \r\n if you specify "&lineendings=pc", which I'm not. I'll give it a go and see if it makes a difference...
(Reply) (Parent) (Thread)
[User Picture]From: credendovides
2002-04-11 03:38 pm (UTC)
Well the protocol is HTTP. HTTP is based off of telnet. So based on that, technically all line endings must be CR/LF. However, it only matters up to and including the blank line. After that, as long as the content interpreter (The LJ server) can deal with it, it's fine. In this case, it's fine. Just make sure the content length is correct. But the blank line after the header should still be a CR/LF.
(Reply) (Parent) (Thread)