in reply to Re^2: Using perl to grab msn and yahoo contacts
in thread Using perl to grab msn and yahoo contacts

I have written the following code. Only problem is that in the final part, it doesnot give output i.e. for this line: snd_msg( $socket, 'USR 4 TWN S t='.$final."\r\n" ); print (get_msg( $socket )."\n\n"); i dont know why but it just doesnt print anything and the perl interpreter keeps running. i dont know why. the rest all is right. All the code i have written as per the guidelines from: http://www.hypothetic.org/docs/msn/notification/authentication.php Thank you very much, Anant

#!/usr/bin/perl use Digest::MD5 qw(md5 md5_hex md5_base64); use FileHandle; use Socket; use LWP; $login = 'yourname@msn.com'; $pass = 'yourpassword'; ### $ds = 'messenger.hotmail.com'; $port = '1863'; $| = 1; $id = 1; $socket = msnp_connect( $ds, $port ); snd_msg( $socket, "VER 1 MSNP11 CVR0\r\n" ); print (get_msg( $socket )."\n\n"); snd_msg( $socket, "CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS +$login\r\n" ); print (get_msg( $socket )."\n\n"); snd_msg( $socket, "USR 3 TWN I $login\r\n" ); print (get_msg( $socket )."\n\n"); close( $socket ); $ds = "207.46.110.94"; $socket = msnp_connect( $ds, $port ); snd_msg( $socket, "VER 1 MSNP11 CVR0\r\n" ); print (get_msg( $socket )."\n\n"); snd_msg( $socket, "CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS +$login\r\n" ); print (get_msg( $socket )."\n\n"); snd_msg( $socket, "USR 3 TWN I $login\r\n" ); $tickets = (get_msg( $socket )."\n\n"); $tickets =~ m/lc=(.*)/; $ticket = "lc="."$1"; print $ticket; print "\n\n"; $link = "https://nexus.passport.com/rdr/pprdr.asp"; my $browser = LWP::UserAgent->new; $response = $browser->get( $link ); $passporturl = $response->headers->header("PassportURLs"); $passporturl =~ m/DALogin=(.*?),/; $dalogin = "https://".$1; print $dalogin; print "\n\n"; $auth = q!Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn% +2Ecom,sign-in=!; $auth .= "$login"; $auth .= ",pwd="; $auth .= "$pass"; $auth .= ","; $auth .= $string; $response = $browser->get($dalogin, 'Authorization' => "$auth"); $final = $response->headers->header("Authentication-Info"); #if ($response->headers->header("Authentication-Info") != '') { # $final = $response->headers->header("Authentication-Info"); #} else { # $final = $response->headers->header("WWW-Authenticate"); #} #print $response->headers->header("Location"); print $final; print "\n\n"; $final =~ m/from-PP='t=(.*)'/; $final = $1; print "$final\n\n"; snd_msg( $socket, 'USR 4 TWN S t='.$final."\r\n" ); print (get_msg( $socket )."\n\n"); close ($socket); exit; sub msnp_connect { my ( $sv, $port ) = @_; my $socket; my $ip = inet_aton( $sv ); my $sockaddr = pack_sockaddr_in( $port, $ip ); socket( $socket, PF_INET, SOCK_STREAM, 0 ); connect( $socket, $sockaddr ); autoflush $socket 1; return $socket; } sub snd_msg { my ( $socket, $buff1 ) = @_; print $socket $buff1; print "TX: $buff1" if ( $Debug ) ; } sub get_msg { my ( $socket, $buff1 ) = @_; my $line; eval { local $SIG{ALRM} = sub { die "timeout" }; alarm $timeout; while ( 1 ) { $line = <$socket>; print "RX: $line" if ( $Debug ) ; if ( $line =~ /$buff1/ ) { last; } } alarm 0; }; alarm 0; if ( $@ ) { if ( $@ =~ /timeout/ ) { print "TIMEDOUT"; exit; } } $line =~ s/[\r\n]//g; return $line; }

Replies are listed 'Best First'.
Re^4: Using perl to grab msn and yahoo contacts
by user2000 (Sexton) on Sep 07, 2007 at 17:57 UTC
    I have written the following code. However on the ifnal login i get a 911 error which means authentication failed. I have followed the guidelines exactly. Can someone help me in the same.