Top.Mail.Ru
? ?
lj_dev, posts by tag: code: php - LiveJournal [entries|archive|friends|userinfo]
LiveJournal Development

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Generating an ECP hash. [Jun. 19th, 2008|01:13 am]
LiveJournal Development
professormass
[Tags|, , , , ]
[mood |annoyedannoyed]

(Bumping this up from earlier comments in the hopes of assistance.)

I'm stuck on one issue. I've used the form sent out via comment emails as a basis, but I'm having a hard time generating the ECP hash.

In talklib.pl, the hash is generated like so:




sub ecphash {
my ($itemid, $talkid, $password) = @_;
return "ecph-" . Digest::MD5::md5_hex($itemid . $talkid . $password);
}





In PHP, I'm doing this:




$TalkID = '1010';
$ItemID = '010101';
$Password = 'mypassword';
$ECPHash = md5($ItemID . $TalkID . $Password);





However, the submitted form is rejecting the hash as having the wrong password. Is there some further munging of the password that needs to be done to generate a valid password for hashing? Or is the PHP md5() doing something different than the Perl library?

Now, I know the TalkID and the ItemID aren't the problem, which leaves me with one of two options:

1) The MD5 hashing functions work differently between PHP and Perl (which would be odd).

2) The password being used to generate the hash on LJ's side is not a clear-text password, but rather some sort of encrypted form of the password being pulled from their database

Any clues?

Edited To Add: Thank you, soph! Here is the fixed and working code:





	$Journal = 'JournalReceivingReply';
	$Poster = 'UsernameOfReplyingParty';
	$TalkID = '01010';
	$DItemID = '101010';
	$JItemID = intval($DItemID/256);
	$Password = 'apassword';
	$ECPHash = md5($JItemID . $TalkID . $Password);

	echo '
<html>
	<body>
		<form method="post" target="ljreply" action="http://www.livejournal.com/talkpost_do.bml">
			<input type="hidden" name="usertype" value="user" />
			<input type="hidden" name="parenttalkid" value="' . $TalkID . '" />
			<input type="hidden" name="itemid" value="' . $ItemID . '" />
			<input type="hidden" name="journal" value="' . $Journal . '" />
			<input type="hidden" name="userpost" value="' . $Poster . '" />
			<input type="hidden" name="ecphash" value="ecph-' . $ECPHash . '" />
			<input type="hidden" name="encoding" value="windows-1252" />
			<b>Subject:</b> <input name="subject" size="40" value="" />
			<p><b>Message:</b>
			<br />
			<textarea rows="10" cols="50" wrap="soft" name="body"></textarea>
			<br />
			<input type="submit" value="Post Reply" />
		</form>
	</body>
</html>
	';



link11 comments|post comment

editfriends XML-RPC issue. [Jun. 16th, 2008|03:43 am]
LiveJournal Development
professormass
[Tags|, , , ]
[mood |annoyedannoyed]

Hi!

I'm trying to get my PHP-based XML-RPC client update friends' lists using the editfriends method, but I'm getting an odd response. Here's my PHP code:




require('Configuration/Configuration.php');
require($FunctionRoot . 'xmlrpc.php');

// LJ XML-RPC Variables
$add = array();
$add['username'] = 'user_to_be_friended';
$add['fgcolor'] = '#00688B';
XMLRPC_prepare($add,'struct');

$array = array();
$array['username'] = 'professormass';
$array['password'] = 'my_password';
$array['add'] = $add;

XMLRPC_prepare($array,'struct');

$result = XMLRPC_request('www.livejournal.com','/interface/xmlrpc','LJ.XMLRPC.editfriends', array($array));




I get this response:



Application failed during request deserialization: wrong element 'username'



Virtually the exact same code works for using the postevent method. Anybody have any clues on this one?
link1 comment|post comment

My bug ...LJ.XMLRPC [Feb. 13th, 2008|07:05 pm]
LiveJournal Development

todjig
[Tags|, , ]

There is error ?
please help .

write in php + LJ.XMLRPC

$message = new xmlrpcmsg('LJ.XMLRPC.consolecommand');
$message->addParam(xmlrpc_encode(array(
"username" => $Puser,
"password" => $Ppass,
"hpassword" => md5($Ppass),
"clientversion" => "Clops-Connector/0.0.2",
"lineendings" => "0x0A",
"commands" => "help print"
)));
link3 comments|post comment

Can't read protected entries after authenticating [Jan. 3rd, 2008|05:42 am]
LiveJournal Development
scalderwood
[Tags|, , , , ]

Dear all,

I have written a php script through which to interface with LJ's XML-RPC interface (http://www.ratiosemper.com/xmlrpc.phps).  When I supply the correct information, I can login correctly, generate a session cookie, store the session cookie, and access other parts of the LJ site that cannot be accessed via the XML-RPC interface, such as uploading user pics.  I can even post and edit friend-locked entries in communities or journals.

The problem is this: when accessing the RSS feed for the community (or user), it does not display the protected entries.  (if I try fetching the community or user page, it will also NOT show the protected entries)

Is there something more I should be doing?  Is this even possible (I assume this is possible since LJ-Archive downloads protected entries)?  (I know I can do this by posting my username/password to the login.bml, but I don't want to send my password in the clear.)  (I have also tried sending the cookie as header through $curl->set_headers($header_array) and sending the 'X-LJ-Auth: cookie' header, but that didn't change anything.)

Thanks,
Steve

XML-RPC Class file: http://www.ratiosemper.com/IXR_Library.inc.phps
CURL Class file: http://www.ratiosemper.com/curl_http_client.phps
link2 comments|post comment

Digest auth in PHP through XMLRPC? [Nov. 19th, 2007|09:44 pm]
LiveJournal Development

concrete
[Tags|, , ]
[music |Voga-Turnovszky - Vegetativ]

Hi gang,

Anyone has an example on how to do digest auth in PHP via the XMLRPC interface? I'm writing a friendslocked post browser and it going to take me the better part of the week just to figure out the authentication by myself.

EDIT: I might be out of luck. the XMLRPC API does not support Digest auth, only Challenge auth. It means I can not authenticate as one user and use my credentials to look at another user's post. Des anyone know of a way to use XML to look at a friendlocked post of someone else? Or do I have to page scrape?
link4 comments|post comment

navigation
[ viewing | most recent entries ]