########################################################################################################## # LiveJournal AutoUpdate coded by LaughingLizard http://dinki.mine.nu/word/ # # Compatible with all versions of WordPress http://www.mindfulmusings.net/weblog/ # ########################################################################################################## Instructions for WordPress 1.2+: YOU **HAVE** TO DOWNLOAD THE NEW CLASS-XMLRPC.PHPS FILE FROM THE LINK BELOW IF YOU ARE USING WORDPRESS 1.2 MINGUS http://weblogtoolscollection.com/b2-img/class-xmlrpc.phps RENAME THE FILE TO CLASS-XMLRPC.PHP AND REPLACE THE ORIGINAL FOUND IN WP-INCLUDES FOLDER OF YOUR BLOG 1) If my-hacks.php does not exist, please create a new file called my-hacks.php inside your wordpress root directory. Add to the end of the file. Make sure my-hacks support is turned on in wp-admin. This setting is under options/Miscellaneous in your admin page. Copy the function below to my-hacks.php inside the tags. function ljautoupdate ($content='', $post_title='') { /*ljautoupdate*/ require_once ("wp-includes/class-xmlrpc.php"); $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_smilies($content); $content = convert_chars($content, 'html'); $event = $content; $subject = stripslashes (ereg_replace('[\\]+', '\\', $post_title)); $time_difference = get_settings("time_difference"); $year = date('Y', (time() + ($time_difference * 3600))); $month = date('m', (time() + ($time_difference * 3600))); $day = date('d', (time() + ($time_difference * 3600))); $hour = date('H', (time() + ($time_difference * 3600))); $minute = date('i', (time() + ($time_difference * 3600))); $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 )); $params = array( phpxmlrpc_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 (this is optional if you want ot be able to turn this feature off): 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*/ require_once ("wp-includes/class-xmlrpc.php"); $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_smilies($content); $content = convert_chars($content, 'html'); $event = $content; $subject = $post_title; $time_difference = get_settings("time_difference"); $year = date('Y', (time() + ($time_difference * 3600))); $month = date('m', (time() + ($time_difference * 3600))); $day = date('d', (time() + ($time_difference * 3600))); $hour = date('H', (time() + ($time_difference * 3600))); $minute = date('i', (time() + ($time_difference * 3600))); $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( phpxmlrpc_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.2 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.