— |
#!/usr/bin/env perl
our $VERSION = 'v0.1.4' ;
my $ua = LWP::UserAgent->new;
if ( $#ARGV != 0) {
print "usage: webfinger <user\@host>\n" ;
exit 1;
}
my ( $user , $host ) = ( $ARGV [0] =~ m/^@?([^@]+)@([^@]+)$/)
or die 'Error: "' . $ARGV [0] . q{" Doesn't matches user@host} ;
my $req = HTTP::Request->new(
GET => "https://$host/.well-known/webfinger?resource=acct:$user\@$host" ); $req ->header( 'Accept' => 'application/json,application/xml' );
my $res = $ua ->request( $req );
if ( $res ->is_success) {
print $res ->content;
} else {
print STDERR "Got " , $res ->status_line, " instead of 2xx\n" ;
exit 1;
}
|