########################################################################################################## # LiveJournal AutoUpdate coded by LaughingLizard http://dinki.mine.nu/word/ # # Compatible with all versions of WordPress http://www.mindfulmusings.net/weblog/ # ########################################################################################################## Instructions: 1) If you are using WordPress 1.0+ copy the function below to my-hacks.php inside the php tags. function ljautoupdate ($content='', $post_title='') { /*ljautoupdate*/ $lj_userid = "your lj username"; //Your LiveJournal username, please replace within quotes $lj_passwd = "your lj password"; //Your LiveJournal password, please replace within quotes $lj_method = "LJ.XMLRPC.postevent"; $lineendings = "pc"; $content = stripslashes(stripslashes($content)); $content = convert_bbcode($content); $content = convert_gmcode($content); $content = convert_smilies($content); $content = convert_chars($content, 'html'); //$content = apply_filters('the_content', $content); $event = $content; $subject = $post_title; $time_difference = get_settings("time_difference"); //$timenow = getdate(); $year = date('Y', (time() + ($time_difference * 3600))); //$year = $timenow["year"]; $month = date('m', (time() + ($time_difference * 3600))); //$month = $timenow["mon"]; $day = date('d', (time() + ($time_difference * 3600))); //$day = $timenow["mday"]; $hour = date('H', (time() + ($time_difference * 3600))); //$hour = $timenow["hours"]; $minute = date('i', (time() + ($time_difference * 3600))); //$minute = $timenow["minutes"]; $client = new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80); $x_params_r = array( "username" => utf8_encode( $lj_userid ), "password" => utf8_encode( $lj_passwd ), "lineendings" => $lineendings, "event" => utf8_encode( $event ), "subject" => utf8_encode( $subject ), "year" => utf8_encode( $year ), "mon" => utf8_encode( $month ), "day" => utf8_encode( $day ), "hour" => utf8_encode( $hour ), "min" => utf8_encode( $minute )); //print_r($x_params_r); $params = array( xmlrpc_encode( $x_params_r ) ); $msg = new xmlrpcmsg('LJ.XMLRPC.postevent', $params); $client->setDebug(0); $result = $client->send($msg); if ($result->faultCode() != 0) { print "Couldn't process request: " . $result->faultString(); return; } /*end ljautoupdate*/ } Now modify your livejournal username and password in the function and save the file. Then find post.php inside your wp-admin folder and find: case 'post': and then look for this line: $result = $wpdb->query($postquery); Paste the following code right after that line: if ($content && $post_status == 'publish') ljautoupdate($content, $post_title); #####################################################################################################################3 TO ADD A LITTLE CHECK BUTTON TO THE WP-ADMIN INTERFACE: Find this line in your edit-form.php file (which is inside the wp-admin folder):
Add this right below that(BEFORE the
):    Update LiveJournal Find this line in your edit-form-advanced.php: Add this right below that (BEFORE the ):    Update LiveJournal Find this line you just added in post.php (in your ap-admin folder): if ($content && $post_status == 'publish') ljautoupdate($content, $post_title); And replace it with: $ljautoupdate = $HTTP_POST_VARS['ljautoupdate']; if ($content && $post_status == 'publish' && $ljautoupdate) ljautoupdate($content, $post_title); Now there should be a small checkbox that allows you to control whether to post on LiveJournal or not. #####################################################################################################################3 If you would like to post your entries as "friends only", use this ljautoupdate function (add to your my-hacks.php) instead of the one above: function ljautoupdate ($content='', $post_title='') { /*ljautoupdate*/ $lj_userid = "your lj username"; //Your LiveJournal username, please replace within quotes $lj_passwd = "your lj password"; //Your LiveJournal password, please replace within quotes $lj_method = "LJ.XMLRPC.postevent"; $lineendings = "pc"; $content = stripslashes(stripslashes($content)); $content = convert_bbcode($content); $content = convert_gmcode($content); $content = convert_smilies($content); $content = convert_chars($content, 'html'); //$content = apply_filters('the_content', $content); $event = $content; $subject = $post_title; $time_difference = get_settings("time_difference"); //$timenow = getdate(); $year = date('Y', (time() + ($time_difference * 3600))); //$year = $timenow["year"]; $month = date('m', (time() + ($time_difference * 3600))); //$month = $timenow["mon"]; $day = date('d', (time() + ($time_difference * 3600))); //$day = $timenow["mday"]; $hour = date('H', (time() + ($time_difference * 3600))); //$hour = $timenow["hours"]; $minute = date('i', (time() + ($time_difference * 3600))); //$minute = $timenow["minutes"]; $security = 'usemask'; $allowmask = '1'; $client = new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80); $x_params_r = array( "username" => utf8_encode( $lj_userid ), "password" => utf8_encode( $lj_passwd ), "lineendings" => $lineendings, "event" => utf8_encode( $event ), "subject" => utf8_encode( $subject ), "security" => utf8_encode( $security ), "allowmask" => utf8_encode( $allowmask ), "year" => utf8_encode( $year ), "mon" => utf8_encode( $month ), "day" => utf8_encode( $day ), "hour" => utf8_encode( $hour ), "min" => utf8_encode( $minute )); //print_r($x_params_r); $params = array( xmlrpc_encode( $x_params_r ) ); $msg = new xmlrpcmsg('LJ.XMLRPC.postevent', $params); $client->setDebug(0); $result = $client->send($msg); if ($result->faultCode() != 0) { print "Couldn't process request: " . $result->faultString(); return; } /*end ljautoupdate*/ } All Done for 1.0+ #####################################################################################################################3 For all other versions of wordpress, open wp-post.php (inside wp-admin folder), find: case 'post': and then look for this line: $result = $wpdb->query($postquery); Paste the following code right after that line: /*ljautoupdate*/ $lj_userid = "your lj username"; //Your LiveJournal username, please replace within quotes $lj_passwd = "your lj password"; //Your LiveJournal password, please replace within quotes $lj_method = "LJ.XMLRPC.postevent"; $lineendings = "pc"; $event = $content; $subject = $post_title; $timenow = getdate(); $year = date('Y', (time() + ($time_difference * 3600))); //$year = $timenow["year"]; $month = date('m', (time() + ($time_difference * 3600))); //$month = $timenow["mon"]; $day = date('d', (time() + ($time_difference * 3600))); //$day = $timenow["mday"]; $hour = date('H', (time() + ($time_difference * 3600))); //$hour = $timenow["hours"]; $minute = date('i', (time() + ($time_difference * 3600))); //$minute = $timenow["minutes"]; $client = new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80); $x_params_r = array( "username" => utf8_encode( $lj_userid ), "password" => utf8_encode( $lj_passwd ), "lineendings" => $lineendings, "event" => utf8_encode( $event ), "subject" => utf8_encode( $subject ), "year" => utf8_encode( $year ), "mon" => utf8_encode( $month ), "day" => utf8_encode( $day ), "hour" => utf8_encode( $hour ), "min" => utf8_encode( $minute )); //print_r($x_params_r); $params = array( xmlrpc_encode( $x_params_r ) ); $msg = new xmlrpcmsg('LJ.XMLRPC.postevent', $params); $client->setDebug(0); $result = $client->send($msg); if ($result->faultCode() != 0) { print "Couldn't process request: " . $result->faultString(); return; } /*end ljautoupdate*/ Now modify your livejournal username and password in the code and save the file. This script allows every post that you publish on your WordPress blog to also be published on your LiveJournal site. You cannot edit LiveJournal entries once they are published (through the WP admin page), only publish to it. If there is enough interest, I could come up with that functionality and others such as moods and music. The items sent to LiveJournal are your post title, your post content and the date and time of your post. Enjoy. Please post bugs to http://dinki.mine.nu/word/ Please post bugs.