|Posting from a website
||[Jul. 20th, 2007|01:54 pm]
LiveJournal Client Discussions
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?
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"
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.
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.
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.
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.)
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.
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.
Does a POST request work?
I haven't worked those out yet.