http://qs321.pair.com?node_id=11148975


in reply to Anyone looking at Mastodon::Client?

Well, my bot does it something like this:

print "Connecting to Mastodon...\n"; my $client = Mastodon::Client->new( instance => $config->{server}, name => 'TotallyLegitBot', client_id => $config->{key}, client_secret => $config->{secret}, access_token => $config->{token}, coerce_entities => 1, ); print "Posting message...\n"; $client->post_status('Dear Sir! I am prince Bob of Nigeria and i have +an offer for you...');

Hope that helps.

EDIT: For authentication, i went to my Mastodon account to Preferences/Development, clicked on "New Application", filled in application name and clicked submit. Then click the link with that application again and you get key+secret+token that you give your application. There are probably other ways to authorize it, but that's the one i found works without problems and with the least fuzzing about.

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP

Replies are listed 'Best First'.
Re^2: Anyone looking at Mastodon::Client?
by Cody Fendant (Hermit) on Dec 20, 2022 at 07:15 UTC

    Oh that's great, it works the way you do it. Maybe I misunderstood the workflow. I thought I needed to authorise as a user in the Perl in another step. Thanks!

      There probably is another, more sleek way. Similar on how Twitter does it, when a "do you want to authorize this app" page pops up. And no, couldn't get that to work on Twitter or Mastodon.

      Still using the old Net::Twitter classes for that stuff. Didn't feel the need to upgrade my code when upgrading will probably take longer than the remaining livetime of our formerly beloved social media platform.

      PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP