XML-RPC posting into LJ

Apr 23, 2011 20:20

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... )

client: posting, client, client: php, *unanswered, client: troubleshooting

Leave a comment

Comments 10

pauamma April 23 2011, 18:14:28 UTC
Can you be more specific about what happens than "it doesn't work"?

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

palmindesert April 23 2011, 20:40:52 UTC
The otput, I see in breowser:
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)

palmindesert April 23 2011, 20:56:17 UTC
Of course, it's better to use standart module, but I'm not sure it will exist on my provider's server so I use this library. I now a lot of people are using this Inclutio http://scripts.incutio.com/xmlrpc/ and it works fine. Can it be a reason of confusion?

Reply


isachi April 23 2011, 22:54:01 UTC

$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

isachi April 24 2011, 00:08:49 UTC
Oh excuse me, I just saw on the end of your code you DO print that variable... my bad ^_^ In that case it looks like $LjChallenge = $LjResponse['challenge']; should be $LjChallenge = $LjResponse['auth_response'];??? I don't know... it's hard to tell from the output you've posted o.o

Reply

palmindesert April 24 2011, 10:40:36 UTC
palmindesert April 24 2011, 10:43:39 UTC
I don't now what to think. Everythink looks right, but it dont want to work. Oh!...

Reply


palmindesert April 29 2011, 11:00:43 UTC
And nobody nows how to help me?

Reply


getting 403 Forbidden error r_w_t May 16 2011, 08:50:23 UTC
Hi there,

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

Re: getting 403 Forbidden error palmindesert May 16 2011, 10:07:35 UTC
Hi!
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

Up