The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mastodon::Client - Talk to a Mastodon server

SYNOPSIS

use Mastodon::Client;

my $client = Mastodon::Client->new(
  instance        => 'mastodon.social',
  name            => 'PerlBot',
  client_id       => $client_id,
  client_secret   => $client_secret,
  access_token    => $access_token,
  coerce_entities => 1,
);

$client->post_status('Posted to a Mastodon server!');
$client->post_status('And now in secret...',
  { visibility => 'unlisted ' }
)

# Streaming interface might change!
my $listener = $client->stream( 'public' );
$listener->on( update => sub {
  my ($listener, $status) = @_;
  printf "%s said: %s\n",
    $status->account->display_name,
    $status->content;
});
$listener->start;

DESCRIPTION

Mastodon::Client lets you talk to a Mastodon server.

This distribution is still in development, and the interface might change in the future. But changes should mostly be to add convenience methods for the more common tasks.

The use of the request methods (post, get, etc) is not likely to change, and as long as you know the endpoints you are reaching, this should be usable right now.

ATTRIBUTES

METHODS

Methods listed here follow the order of those in the official API documentation.

Accounts

Apps

Blocks

Favourites

Follow requests

Follows

Instances

Media

Mutes

Notifications

Reports

Statuses

Timelines

STREAMING RESULTS

Alternatively, it is possible to use the streaming API to get a constant stream of updates. To do this, there is the stream() method.

REQUEST METHODS

Mastodon::Client uses four lower-level request methods to contact the API with GET, POST, PATCH, and DELETE requests. These are left available in case one of the higher-level convenience methods are unsuitable or undesirable, but you use them at your own risk.

They all take a URL as their first parameter, which can be a string with the API endpoint to contact, or a URI object, which will be used as-is.

If passed as a string, the methods expect one that contains only the variable parts of the endpoint (ie. not including the HOST/api/v1 part). The remaining parts will be filled-in appropriately internally.

CONTRIBUTIONS AND BUG REPORTS

Contributions of any kind are most welcome!

The main repository for this distribution is on GitLab, which is where patches and bug reports are mainly tracked. The repository is also mirrored on Github, in case that platform makes it easier to post contributions.

If none of the above is acceptable, bug reports can also be sent through the CPAN RT system, or by mail directly to the developers at the address below, although these will not be as closely tracked.

AUTHOR

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by José Joaquín Atria.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.