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.
|