Андрей (palmindesert) wrote in lj_dev,
Андрей
palmindesert
lj_dev

XML-RPC posting into LJ

Hi, dear LJ developers! I'm creating a remote poster to LiveJournal for my site. This is the code i've wroute:

<?php
include ('IXR_Library.php');

$LjPass = $_POST['LjPass'];
$LjPassEncrypted = md5($LjPass);
$LjLogin = $_POST['LjLogin'];
$Auth = 'challenge';

$postSub = $_POST['postSub'];
$postText = $_POST['postText'];
$tags = array();
$postTime = $_POST['postTime'];
$postSecurity = $_POST['postSecurity'];

$LJ = new IXR_Client('http://www.livejournal.com/interface/xmlrpc');

if(!$LJ->query('LJ.XMLRPC.getchallenge')){
    echo 'Error!!!'.$ljClient->getErrorMessage();
}
else{
    $LjResponse = $LJ->getResponse();
    $LjChallenge = $LjResponse['challenge'];
    $ljContentToSend = array();
    $ljContentToSend['username'] = $LjLogin;
    $ljContentToSend['auth_method'] = 'challenge';
    $ljContentToSend['auth_response'] = md5($LjChallenge.md5($LjPass));
    $ljContentToSend['ver'] = '1';
    $ljContentToSend['event'] = $postText;
    $ljContentToSend['subject'] = $postSub;
    //date
    $ljContentToSend['year'] = $postTime['year'];
    $ljContentToSend['mon'] = $postTime['month'];
    $ljContentToSend['day'] = $postTime['day'];
    $ljContentToSend['hour'] = $postTime['hour'];
    $ljContentToSend['min'] = $postTime['minuts'];
    $ljContentToSend['props'] = array(
                                      'opt_preformated' => true,
                                      'opt_backdated' => true,
                                      'taglist' => $tags
                                      );
    $ljContentToSend['security'] = $postSecurity;
    echo '<br>';
    print_r ($ljContentToSend);
    echo'<br>';
   
    $LjMethod = 'LJ.XMLRPC.postevent';
   
    $LJ->query($LjMethod, $ljContentToSend);
   
    $LjResponse = $LJ->getResponse();
    print_r ($LjResponse);
    $LjError = $LJ->getErrorMessage();
    echo $LjError.'<br>';
    echo $LjSecurePass.'<br>';
    echo $ljContentToSend['auth_response'].'<br>';
    echo $LjPass.'<br>';
    echo $LjPassEncrypted.'<br>';
};
   
?>


Looks fine, but doesn't work :). Please, let me now, what's wrong?
Tags: *unanswered, client, client: php, client: posting, client: troubleshooting
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 11 comments