?

Log in

No account? Create an account
Posting from a website - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

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

Posting from a website [Jul. 20th, 2007|01:54 pm]
LiveJournal Client Discussions

lj_clients

[zombywuf]
Hi, I'm wanting to make a web app that will provide a "Post this to Livejournal" style functionality. Either a link to the site or embedding media. I'd like it to be as simple as possible, i.e. a link that will take you straight to the "Update Journal" page with the embedded stuff/link already filled in and the user only having to add comments if they want and hit the post button. Anyone here know how I'd go about doing that?

Failing that, is there anything publicly available that will provide this functionality?
linkReply

Comments:
[User Picture]From: t3knomanser
2007-07-20 02:03 pm (UTC)
A simple javascript link could do it. document.location = "the update page";document.getElementById(whatever the field on the LJ form you want filled in).value="what you're filling it in with"

It should be a pretty trivial javascript exercise.
(Reply) (Thread)
[User Picture]From: zombywuf
2007-07-20 02:31 pm (UTC)
That doesn't work, the document object will not become the document you want. If it did work it would be a pretty major cross site scripting hole. However, I found a method that does work here: http://ljrelated.black-piano.com/.

Just add subject and event params with the subject and prefill text as args respectively and it does exactly what I need.
(Reply) (Parent) (Thread)
[User Picture]From: t3knomanser
2007-07-20 02:35 pm (UTC)
That makes sense. I've got a few bookmarklets I use that do something along those lines- but I've never really delved into the code. Now that I think about it, a nicer way of doing it would be to retrieve the LJ form via an XMLHTTPRequest (grab the whole page, identify the form element, extract that from the response) and the display it in a floating div. More work, especially due to cross browser stuff, but really really flexible.

Of course, if someone's already done the work, there's no point in reinventing the wheel.
(Reply) (Parent) (Thread)
[User Picture]From: aveleh
2007-07-20 02:44 pm (UTC)
If I was doing it, I'd sent it as a GET.

Just create a form that will send something like this:

http://www.livejournal.com/update.bml?&subject=Post+Subject+Goes+Here&event=insert+post+text+here

You can also have it add a particular tag (check out Writer's Block on the homepage for an example) and although I haven't tested, you can also do fancy hings like make it post to a journal, select a non-default userpic if they have one with a given keyword, fill in the mood or the location or the music, change the security, change comment settings.

You can pretty much see what all the options are called just by reading the page source.
(Reply) (Thread)
[User Picture]From: allah_sulu
2007-07-20 03:43 pm (UTC)
Just create a form that will send something like this:

That only works for very short posts; and if there's any HTML or other "abnormal" characters in your post text, you'll have to convert them ("<" into "%3C", etc.)
(Reply) (Parent) (Thread)
[User Picture]From: zombywuf
2007-07-26 09:01 pm (UTC)
Well urlencoding is a given. The data I want to post is short so this works fine. Now I just need to get it developed.
(Reply) (Parent) (Thread)
[User Picture]From: allah_sulu
2007-07-27 10:47 am (UTC)
I compose my LJ posts in an HTML editor of my own creation, with a built-in scripting language- but when I'm done, I have to copy/paste the code into LJ because I haven't worked out yet how to get my program to link into LJ directly.

After reading this, I wrote a macro to urlencode special characters open it up in a broswer- that's why I saw that there's a definite size limit.

Most of my posts are too long, so I'll continue with the copy/paste; but I have the macro now for short ones... Until I get around to working out how to get my program to post directly.
(Reply) (Parent) (Thread)
[User Picture]From: zombywuf
2007-07-27 11:13 am (UTC)
Does a POST request work?
(Reply) (Parent) (Thread)
[User Picture]From: allah_sulu
2007-07-27 11:47 am (UTC)
I haven't worked those out yet.
(Reply) (Parent) (Thread)
[User Picture]From: allah_sulu
2007-07-27 12:19 pm (UTC)
This works:
http://www.scalabium.com/faq/dct0139.htm

It automatically does the urlencoding for me, and it supports a much longer post.
(Reply) (Parent) (Thread)
[User Picture]From: allah_sulu
2007-07-28 03:26 pm (UTC)
(Reply) (Parent) (Thread)