Posting from a website

Jul 20, 2007 13:54

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 ( Read more... )

Leave a comment

Comments 11

t3knomanser July 20 2007, 14:03:57 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

zombywuf July 20 2007, 14:31:50 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

t3knomanser July 20 2007, 14:35:58 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


aveleh July 20 2007, 14:44:37 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

allah_sulu July 20 2007, 15:43:30 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

zombywuf July 26 2007, 21:01:47 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

allah_sulu July 27 2007, 10:47:16 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


Leave a comment

Up