Created
May 4, 2017 20:34
-
-
Save lolicsystem/61d098f2d3a505ef52acae9957fd4856 to your computer and use it in GitHub Desktop.
pawooていうかマストドンで特定ユーザのフォロワー(またはフォロー)一覧を得るスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
片思い・片思われや、フォロー・フォロワー推移調査等にどうぞ( ´ ▽ ` )ノ