Home
LiveJournal Client Discussions - Delicious Glue [entries|archive|friends|userinfo]
LiveJournal Client Discussions

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

Delicious Glue [Jun. 10th, 2006|06:36 am]
Previous Entry Add to Memories Tell a Friend Next Entry

lj_clients

[nounverb]
Hello,

I've recently developed a LiveJournal client for del.icio.us's Daily Post feature. I call it delicious glue, because paste is a nutritious treat for our children. Built off of Incutio's XMLRPC Library, this PHP script only needs to be placed into a directory which can run PHP on a webserver.

You pretty much take the script and point del.icio.us's daily post URL at the URL you upload the script to. You also must configure del.icio.us to have your LJ username and password, which is sent via handshake from the script to post the information.

Delicious Glue

An Example Post
Another Example Post

I've recently added <>& stripping (something I overlooked) due to the code. However, another bug I've encountered recently is that (I am presuming) if the code contains a mix of language encoding data (here again), one cannot go back and edit it. Switching my default journal encoding-from will only break this post. This has happened with other people.

I am not sure if this is the problem with me not manually setting Unicode with my script somewhere, but I presume all the data is Unicode due to my script pretty much transforming from metaWeblog to XMLRPC.

Please download and try my script and give me feedback!
linkReply

Comments:
From: [info]hashem
2006-06-16 06:03 am (UTC)

(Link)

I'm interested in setting this up, but I've got a question: What number goes in the "out_blog_id" field?
[User Picture]From: [info]nounverb
2006-06-16 11:32 am (UTC)

(Link)

it's irrelevant, as long as the login information is correct. i'd put "1", though.
From: [info]hashem
2006-06-16 01:26 pm (UTC)

(Link)

Not to be a bother, but I've been encountering an error:

results:Running at Fri Jun 16 13:18:31 2006 GMT
Fetched 1 items.
posting error was: syntax error postLJResponse : Something went wrong - 101 : Invalid password at /home/joshuas/utilities/dohour line 81


The username and password I've entered is correct, the link I provided is correct, my server CAN run PHP, etc. I'm not quite sure what the problem is, and attempting to solve it on my own is becoming quite irritating as it takes an hour to see whether the change worked or not.
[User Picture]From: [info]nounverb
2006-06-16 02:03 pm (UTC)

(Link)

What the app does is construct an MD5 hash of the handshake hash LJ sends it and your password. Now, I am not exactly sure what is going on here, as this does no altering of your password beyond creating the hash.

Can you tell me what version of PHP you're running? Does your password contain any non-numerical or non-alphabetic passwords (I don't think this would matter, but it is something I have not deliberately checked against yet)?

The current way I get debug output is for it to connect to an SQL server and leave a copy of information there.

In either case, I added some extra debugging output for the script to display on this error, so maybe we can solve this together.

http://web.njit.edu/~js84/php/delicious-glue.zip
From: [info]hashem
2006-06-16 02:16 pm (UTC)

(Link)

what version of PHP you're running
PHP Version 4.4.2.

Does your password contain any non-numerical or non-alphabetic passwords
No, only letters and numbers.

In either case, I added some extra debugging output for the script to display on this error, so maybe we can solve this together.
Alright, I uploaded it. I assume I just wait for del.icio.us to do it's next daily blog update?
[User Picture]From: [info]nounverb
2006-06-16 03:13 pm (UTC)

(Link)

yeah, this was one of the main problems I had when developing it, I had to wait all day to capture output, it is annoying
From: [info]hashem
2006-06-16 03:25 pm (UTC)

(Link)

I think I figured out the problem: My main username starts with a "0", and apparently, when going through the scripts, it omits the "0", only leaving the second half. So, that might need to be corrected (unless it's an error on del.icio.us's side).
From: [info]hashem
2006-06-16 02:20 pm (UTC)

(Link)

All right, it works now. Thanks.
[User Picture]From: [info]kulhazker
2006-09-22 08:51 am (UTC)

(Link)

how to use script ???

upluad and run ?

see - XML-RPC server accepts POST requests only.

how to configure ?
[User Picture]From: [info]nounverb
2006-09-24 07:24 am (UTC)

(Link)

The script only relays the information.

http://www.lifehacker.com/software/delicious/how-to-back-up-delicious-bookmarks-on-your-blog-159861.php

You set the URL as wherever you uploaded the script to.
[User Picture]From: [info]aileron
2006-10-01 03:47 am (UTC)

this is great!

(Link)

thank you! i've been waiting for something like this for a long time.

i was also wondering whether there's a way to format the post via the php end, particularly to insert the <lj-raw> tag at the beginning of the post.
[User Picture]From: [info]nounverb
2006-10-02 02:52 am (UTC)

Re: this is great!

(Link)

You can edit this into the script, I don't have the code on me right now, however, you can easily prepend or append this. The variable you edit is $junk, which is just the XML of the post.
[User Picture]From: [info]aileron
2006-10-02 08:31 am (UTC)

no more extra line breaks!

(Link)

thanks again. i added

$junk=ereg_replace("<ul class=\"delicious\">", "<lj-raw><ul class=\"delicious\">", $junk);

i'm sure there's another way but this worked for me.
[User Picture]From: [info]merkwurdig
2007-02-05 06:55 pm (UTC)

(Link)

how can i post friends-only post with this script? it is something in 'props' parameter of struct that goes as part of $response to LJ.XMLRPC.postevent, but i couldn't find how can this be done. can you help?
[User Picture]From: [info]kate_nepveu
2007-10-04 01:32 am (UTC)

(Link)

Did anyone ever determine how to do this?
[User Picture]From: [info]nounverb
2007-10-04 03:39 am (UTC)

(Link)

Sorry it's been awhile since I've had to work on this or the LJ API. I can take a look at it sometime soon.
[User Picture]From: [info]kate_nepveu
2007-10-04 10:50 am (UTC)

(Link)

Thanks, I appreciate it. It's a great script, and this would make it even better.
[User Picture]From: [info]merkwurdig
2007-10-04 08:22 am (UTC)

(Link)

if you want to do something right, do it yourself.

function constructResponse($username,$safeword,$results,$postdata)
{
    // This is where you can reformat post information and set privacy levels.
    // I should make this more usable at the expense of "good" code.
    // Change the 'taglist' to change the tags the client uses.
    $options =
    array(
        'taglist'=>"links"
    );
    $event = $postdata;
    $year = date('Y');
    $mon = date('n');
    $day = date('j');
    $hour = date('G');
    $min = date('i');
    $subject = 'Links for '.$day.'-'.$mon.'-'.$year;
    $security = 'usemask';
    $allowmask = '1';
    $r =
    array(
        'username'=>$username,
        'auth_method' => 'challenge',
        'auth_challenge' => $results['challenge'],
        'auth_response' => $safeword,
        'event' => $event,
        'subject' => $subject,
        "security" => utf8_encode( $security ),
        "allowmask" => utf8_encode( $allowmask ),
        'year' => $year,
        'mon' => $mon,
        'day' => $day,
        'hour' => $hour,
        'min' => $min,
        'ver' => '1',
        'props' => $options
    );
[User Picture]From: [info]kate_nepveu
2007-10-04 10:49 am (UTC)

(Link)

Yes, I saw that in the code. However, my knowledge of PHP is limited to modifying other people's "if x, then print y" statements, so I don't know what to _do_ with it.
[User Picture]From: [info]merkwurdig
2007-10-04 03:28 pm (UTC)

(Link)

just add strings marked with bold to function constructResponse, and posts will be "friends only". it is a very simple task.
[User Picture]From: [info]kate_nepveu
2007-10-04 03:30 pm (UTC)

(Link)

Ah. Thank you, I hadn't understood that from your prior comment. I appreciate the help.
[User Picture]From: [info]merkwurdig
2007-10-04 03:34 pm (UTC)

(Link)

don't forget ver string, it won't work without it.
[User Picture]From: [info]kate_nepveu
2007-10-04 07:33 pm (UTC)

(Link)

That did it, thanks very much.
[User Picture]From: [info]kate_nepveu
2007-10-04 08:46 pm (UTC)

(Link)

Just to add to your help, here's what to add to post to communities.

In the first set of lines that begin with $, add

$posttojournal = 'comm-name-here';

replacing comm-name-here with the name of a community you have posting access to.

In the second set of lines, add

'usejournal' => $posttojournal,

I've tested this in a sandbox comm and it works.
[User Picture]From: [info]merkwurdig
2007-10-04 08:49 pm (UTC)

(Link)

this is useful, thank you. though i only auto-post to my own journal, this gives interesting opportunities :)
[User Picture]From: [info]kate_nepveu
2007-10-04 08:56 pm (UTC)

(Link)

No problem. Thanks for giving me the idea where to look--I wanted to use this to do something like this without so much hand-coding: http://community.livejournal.com/readercon/274.html

(And if I figure out lj-cuts, I'll report back here too . . . Or, more likely, come crawling back asking for help.)
[User Picture]From: [info]merkwurdig
2007-10-05 08:33 am (UTC)

(Link)

you mean lj-cut that covers autopost? you want to autopost lj-cutted messages?
[User Picture]From: [info]kate_nepveu
2007-10-05 12:53 pm (UTC)

(Link)

Yup. Regular lj-cuts I can manage. =>

I've tried [info]nounverb's suggestion at the bottom of comments to this post, which has a typo somewhere and caused the script to throw an error message about unenclosed or unexpected variables (I foolishly didn't write it down). My best guesses at similar or related fixes haven't worked, but delicious didn't throw any error messages, just said it was a new job and hadn't run yet, several hours after the time for it to run.

For the moment, I give up; I can always add lj-cuts by hand, after all.
[User Picture]From: [info]merkwurdig
2007-10-05 03:09 pm (UTC)

(Link)

well, right now del.icio.us giving me error 500 on any actions (adding, settings), but i added "lj-cut" to script on my server, and if it works, i will help you again :)
[User Picture]From: [info]kate_nepveu
2007-10-05 04:05 pm (UTC)

(Link)

Thank you!
[User Picture]From: [info]merkwurdig
2007-10-06 04:57 pm (UTC)

(Link)

adding lj-cut was easy thing (like i thought), and the whole function: (all strings i've added to this function are bold)

function constructResponse($username,$safeword,$results,$postdata)
{
    // This is where you can reformat post information and set privacy levels.
    // I should make this more usable at the expense of "good" code.
    // Change the 'taglist' to change the tags the client uses.
    $options =
    array(
        'taglist'=>"links"
    );
    $postdata = "<lj-cut text=\"texthere\">" . $postdata . "</lj-cut>";
    $event = $postdata;
    $year = date('Y');
    $mon = date('n');
    $day = date('j');
    $hour = date('G');
    $min = date('i');
    $subject = 'Links for '.$day.'-'.$mon.'-'.$year;
    $security = 'usemask';
    $allowmask = '1';
    $r =
    array(
        'username'=>$username,
        'auth_method' => 'challenge',
        'auth_challenge' => $results['challenge'],
        'auth_response' => $safeword,
        'event' => $event,
        'subject' => $subject,
        "security" => utf8_encode( $security ),
        "allowmask" => utf8_encode( $allowmask ),
        'year' => $year,
        'mon' => $mon,
        'day' => $day,
        'hour' => $hour,
        'min' => $min,
        'ver' => '1',
        'props' => $options
    );
    return $r;
}
[User Picture]From: [info]kate_nepveu
2007-10-07 12:49 pm (UTC)

(Link)

Thanks again, it worked great! I really appreciate it.

(And now I can add something else to the start & end of the post if I want, with your model--so double bonus.)
[User Picture]From: [info]merkwurdig
2007-10-07 08:08 pm (UTC)

(Link)

from this point i think you have everything to do anything with posts :)
[User Picture]From: [info]nounverb
2007-10-04 09:49 pm (UTC)

(Link)

Well thanks so much, I'll ad this in when I can
[User Picture]From: [info]extraonions
2007-07-09 06:43 am (UTC)

(Link)

Hi, I'm really excited about this script... I've set it up to try it out and will let you know how it goes. I do have a question-- any way to set the script to automatically either set the links behind a lj-cut tag (so you don't spam your flist with the 98348758 links you happened to tag that day) or to automatically set a filter for the post to go to? Thanks!
[User Picture]From: [info]nounverb
2007-07-09 11:36 am (UTC)

(Link)

Mmm yeah, in one of the regular expressions you could probably add the lj-cut tag. I've kind of dropped this project for a little bit while learning Python but I will see if there is some way I can make it more modular.

You could add a line right above 94 to:

$junk = "&lgt;lj-cut text=\"links\">

And then change line 94 to
$junk .= $args[3]['description']

or something like that

[User Picture]From: [info]extraonions
2007-07-09 03:03 pm (UTC)

(Link)

Thank you! I've uploaded a test version to try and will let you know how it goes... is there really supposed to be a . before the = in line 94, because otherwise I don't see a change to make on that line? Thanks so much for your help with this!