Hi, dear LJ developers! I'm creating a remote poster to LiveJournal for my site. This is the code i've wroute:
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
(
Read more... )
Comments 10
Also, in if(!$LJ->query('LJ.XMLRPC.getchallenge')){
echo 'Error!!!'.$ljClient->getErrorMessage();
}you use $ljClient, but I don't see that initialized anywhere. Should that be $LJ instead?
Reply
Array ( [username] => MyUserName [auth_method] => challenge [auth_response] => 23b64cf8c64111ed3380ef02e175794b [ver] => 1 [event] => [subject] => [year] => [mon] => [day] => [hour] => [min] => [props] => Array ( [opt_preformated] => 1 [opt_backdated] => 1 [taglist] => Array ( ) ) [security] => publick ) //this is content we send
Array ( [faultString] => Invalid password [faultCode] => 101 ) Invalid password // This is answer from LJ server
23b64cf8c64111ed3380ef02e175794b//this is challenge
MyPass//Pass
279bf6fda506e1ed6350dc671d0ef63e//pass md5
Yes, it's not inicialized anywhere. It's strange, but if LJ.XMLRPC.getchallenge does not exist it's impossible to get the challenge, but we do this. I'm confused this... :)
Anyway, error is "invalid password", that is the challenge incorect(is the pass-challenge operations right?). I feel a fool :)
Reply
(The comment has been removed)
Reply
$LjResponse = $LJ->getResponse();
$LjChallenge = $LjResponse['challenge'];
First thing I would do is print_r the $LjResponse variable and make sure the array looks the way you think it does. I've never worked with this library but 'incorrect password' suggests to me that what's stored in $LjResponse is an error instead of the challenge.
Unless someone has actually used this library to do what you want to do the best way to debug it is to take it apart bit by bit, commenting out code and printing variables.
I will say that you're variables look suspicious because LJ needs to be given more information about the data for the postevent. For example I have LJ posting on my website are our variables look like this:
$post = array ( ... )
Reply
Reply
Reply
Reply
Reply
Sometime ago (can't remember when) I'm getting an error "403 Forbidden". A little investigation shows that problem occur at the beginning:
$xmlRpcClient = new Zend_XmlRpc_Client('http://www.livejournal.com/interface/xmlrpc');
try {
$chalengeResponse = $xmlRpcClient->call('LJ.XMLRPC.getchallenge');
} catch(Zend_XmlRpc_Client_HttpException $e) {
var_dump( $e->getCode() . ': ' . $e->getMessage() );
}
Output: "403: Forbidden".
Any help?
Thanks
Reply
I've developed new code, it seems to me, it must work, just add XML answer parsing. A little time after I'll show this, if it will work. I believe!
debug = true;
$LjChallenge = $LjServer->query('LJ.XMLRPC.getchallenge');
print_r($LjChallenge);
$LjData = array(
'username' => $LjLogin,
'auth_method' => 'challenge',
'auth_challenge' => $LjChallenge,
'auth_response' => md5($LjChallenge.md5($LjPass)),
'subject' => $postSub,
'event' => $postText,
'props' => array(
'backdated' => true,
'tags' => $tags
),
'year' => $postTime['year'],
'mon' => $postTime['mon'],
'day' => $postTime['day'],
'hour' => $postTime['hour'],
'min' => $postTime['min'],
);
$LjServer->query('LJ.XMLRPC.postevent', $LjData);
?>
Reply
Leave a comment