Skip to content

Instantly share code, notes, and snippets.

@lolicsystem
Created May 4, 2017 20:34
Show Gist options
  • Save lolicsystem/61d098f2d3a505ef52acae9957fd4856 to your computer and use it in GitHub Desktop.
Save lolicsystem/61d098f2d3a505ef52acae9957fd4856 to your computer and use it in GitHub Desktop.
pawooていうかマストドンで特定ユーザのフォロワー(またはフォロー)一覧を得るスクリプト
#!/usr/bin/env perl
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use feature qw/say/;
my $instance = 'pawoo.net';
my $id = 'xxxxx';
my $access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
my $target = 'followers'; # or 'following'
my $ua = LWP::UserAgent->new;
my $header = HTTP::Headers->new ('Authorization' => "Bearer $access_token");
my $url = "https://$instance/api/v1/accounts/$id/$target";
do {
my $request = HTTP::Request->new("GET", $url, $header);
my $response = $ua->request($request);
my @links = split /,/, $response->header('Link');
$url = '';
for (@links) {
if (/rel="next"/) {
/<([^<>]+)>/;
$url = $1;
}
}
my $a = decode_json($response->content);
say $_->{acct} for @$a;
} while $url ne '';
@lolicsystem
Copy link
Author

片思い・片思われや、フォロー・フォロワー推移調査等にどうぞ( ´ ▽ ` )ノ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment