App-ActivityPubClient
view release on metacpan or search on metacpan
script/ap-backup view on Meta::CPAN
use LWP::UserAgent;
use MIME::Base64;
use JSON;
=head1 NAME
ap-backup - Backup an ActivityPub account
=head1 SYNOPSIS
B<ap-backup.pl> <-u user:password|-o OAuth-Bearer-Token> <url>
=head1 DESCRIPTION
ap-backup is used to backup an ActivityPub account, authentication is required.
=over 4
=item B<-u>
HTTP Basic Auth
script/ap-backup view on Meta::CPAN
die "Got ", $content_type, " instead of ", $content_match;
}
} else {
die "Got ", $res->status_line, " instead of 2xx";
}
}
getopts("u:o:", \%options);
if ($#ARGV != 0) {
print "usage: ap-backup.pl <-u user:password|-o OAuth-Bearer-Token> <url>\n";
exit 1;
}
if (defined $options{u}) {
$auth = "Basic " . encode_base64($options{u});
}
if (defined $options{o}) {
$auth = "Bearer " . $options{o};
}
script/ap-fetch view on Meta::CPAN
=item B<-j>
Pipe into jq(1)
=item B<-r>
Raw output, print server's output without any decoding
=item B<-u user:pass>
Pass username and password for HTTP Basic Auth.
=back
=head1 LICENSE
BSD-3-Clause
=cut
my %options = ();
script/ap-fetch view on Meta::CPAN
print
"By default, when -j and -r are absent it pipes the data into ap-represent.pl.\n";
exit 1;
}
$ua->agent("AP-Client fetch <https://hacktivis.me/git/ap-client/>");
my $req = HTTP::Request->new(GET => $ARGV[0]);
$req->header('Accept' => 'application/activity+json');
if (defined $options{u}) {
my ($user, $password) = split(/:/, $options{u});
$req->authorization_basic($user, $password);
}
my $res = $ua->request($req);
if ($res->is_success) {
my $content_type = $res->header("Content-Type");
my $content_match = qr{^application/([^+]*\+)?json(; .*)?};
if ($content_type =~ $content_match) {
if (defined $options{r}) {
( run in 0.843 second using v1.01-cache-2.11-cpan-49f99fa48dc )