AnyEvent-MSN
view release on metacpan or search on metacpan
NAME
AnyEvent::MSN - Exactly what you're expecting...
Synopsis
use AnyEvent::MSN;
my $msn = AnyEvent::MSN->new(
passport => 'you@hotmail.com',
password => 'sekrit',
on_im => sub { # Simiple echo bot
my ($msn, $head, $body) = @_;
$msn->im($head->{From}, $body)
}
);
AnyEvent->condvar->recv;
Description
TODO
examples/client.pl view on Meta::CPAN
#!/usr/bin/perl -I../lib
use AnyEvent;
use AnyEvent::MSN;
use 5.012;
$|++;
$AnyEvent::MSN::DEBUG++;
my ($user, $pass) = @ARGV; # XXX - Better to use a GetOpt-like module
my $cv = AnyEvent->condvar;
($user, $pass) = ('anyevent_msn@hotmail.com', 'public');
($user, $pass) = ('msn@penilecolada.com', 'password');
my $reconnect_timer;
#
my $msn = AnyEvent::MSN->new(
passport => $user, # XXX - I may change the name of this arg before pause
password => $pass,
# Extra user info
status => 'AWY',
friendlyname => 'Just another MSN hacker,',
personalmessage => 'This can\'t be life!',
# Basic events
on_connect => sub {
my $msn = shift;
warn 'Connected as ' . $msn->passport;
lib/AnyEvent/MSN.pm view on Meta::CPAN
isa => 'AnyEvent::MSN::Types::Passport',
required => 1,
handles => {
username => sub {
shift->passport =~ m[^(.+)\@.+$];
$1;
},
userhost => sub { shift->passport =~ m[^.+\@(.+)$]; $1 }
}
);
has password => (is => 'ro', isa => 'Str', required => 1);
# Extra stuff from user
has [qw[friendly_name personal_message]] =>
(is => 'ro', isa => 'Str', default => '');
has status => (
is => 'ro',
isa => 'AnyEvent::MSN::Types::OnlineStatus',
default => 'NLN',
writer => 'set_status' # exposed publicly
);
lib/AnyEvent/MSN.pm view on Meta::CPAN
<wsse:PolicyReference URI="%s"></wsse:PolicyReference>
</wst:RequestSecurityToken>
TOKEN
$s->_soap_request(
($s->passport =~ m[\@msn.com$]i
?
'https://msnia.login.live.com/pp550/RST.srf'
: 'https://login.live.com/RST.srf'
),
{}, # headers
sprintf(<<'XML', $s->password, $s->passport, join '', @tokens),
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy" xmlns:wsu="http://docs.o...
<Header>
<wsse:Security>
<wsse:UsernameToken Id="user">
<wsse:Password>%s</wsse:Password>
<wsse:Username>%s</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
<ps:AuthInfo Id="PPAuthInfo" xmlns:ps="http://schemas.microsoft.com/Passport/SoapServices/PPCRL">
<ps:Cookies></ps:Cookies>
lib/AnyEvent/MSN.pm view on Meta::CPAN
=head1 NAME
AnyEvent::MSN - Simple, Less Annoying Client for Microsoft's Windows Live Messenger Network
=head1 Synopsis
use AnyEvent::MSN;
my $msn = AnyEvent::MSN->new(
passport => 'you@hotmail.com',
password => 'sekrit',
on_im => sub { # Simiple echo bot
my ($msn, $head, $body) = @_;
$msn->im($head->{From}, $body)
}
);
AnyEvent->condvar->recv;
=head1 Description
TODO
=head1 Methods
Well, the public bits anyway...
=over
=item new
my $msn = AnyEvent::MSN->new(passport => 'you@hotmail.com', password => 'password');
This constructs a new L<AnyEvent::MSN> object. Required parameters are:
=over
=item C<passport>
This is an email address.
Microsoft calls them C<passport>s in some documentation, C<username> and plain
ol' C<address> in other places. For future versions of the API (think 1.0),
I'm leaning towards the least awkward: C<username>. Just... keep that in mind.
=item C<password>
It's... your... password.
=back
Optional parameters to C<new> include...
=over
=item C<status>
This will be used as your initial online status. Please see the section
t/100_active/101_session.t view on Meta::CPAN
use Test::More;
use lib -f 'BUILD' ? 'lib' : '../../lib';
use_ok 'AnyEvent::MSN';
#{package AnyEvent::MSN; $DEBUG=$DEBUG=1;}
my $cv = AnyEvent->condvar;
my $to
= AnyEvent->timer(after => 60, cb => sub { diag 'Timeout!'; $cv->send });
my $msn = AnyEvent::MSN->new(
passport => 'anyevent_msn@hotmail.com',
password => 'public',
on_connect => sub {
my $s = shift;
pass sprintf 'Connected as %s. Adding self to buddy list...',
$s->passport;
#$cv->send;
$s->add_contact($s->passport);
# $s->remove_buddy($s->passport);
},
( run in 0.611 second using v1.01-cache-2.11-cpan-49f99fa48dc )