Professor Mass (professormass) wrote in lj_dev,
Professor Mass
professormass
lj_dev

  • Mood:

Generating an ECP hash.

(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>
	';



Tags: *revisit, client, client: posting, code: perl, code: php
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