Skip to content

Instantly share code, notes, and snippets.

@genehack
Created October 20, 2014 13:09
Show Gist options
  • Save genehack/dd1a6249088a6ab1f851 to your computer and use it in GitHub Desktop.
Save genehack/dd1a6249088a6ab1f851 to your computer and use it in GitHub Desktop.
Gets the list of users you have muted on Twitter.
#! /usr/bin/env perl
# NOTE: in order to use this, you need to fill in the various tokens in the constructor at the bottom!
package Net::Twitter::Role::Mute;
use Moose::Role;
use Net::Twitter::API;
base_url 'apiurl';
authenticate 1;
twitter_api_method mutes_users_list => (
description => 'Returns users muted by user',
path => 'mutes/users/list',
method => 'GET',
params => [qw/cursor include_entities skip_status/],
booleans => [qw/include_entities skip_status/],
required => [],
returns => 'HashRef',
);
package ThisApp;
use Moose;
use 5.014;
use Net::Twitter;
has access_token => ( is => 'ro' , required => 1 );
has access_token_secret => ( is => 'ro' , required => 1 );
has consumer_key => ( is => 'ro' , required => 1 );
has consumer_secret => ( is => 'ro' , required => 1 );
has traits => (
is => 'ro' ,
isa => 'ArrayRef' ,
required => 1 ,
default => sub { [ qw/ API::RESTv1_1 OAuth Mute InflateObjects / ] }
);
sub run {
my $self = shift;
my $client = Net::Twitter->new(
traits => $self->traits ,
consumer_key => $self->consumer_key ,
consumer_secret => $self->consumer_secret ,
ssl => 1 ,
);
$client->access_token( $self->access_token );
$client->access_token_secret( $self->access_token_secret );
my $data = $client->mutes_users_list();
my $users = $data->{users};
foreach my $u ( @$users ) {
say sprintf " '%s' aka '@%s' -> https://twitter.com/%s" ,
$u->{name} , $u->{screen_name} , $u->{screen_name};
};
}
package main;
ThisApp->new(
access_token => 'Fill' ,
access_token_secret => 'These' ,
consumer_key => 'All' ,
consumer_secret => 'In' ,
)->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment