This is all of the Ruby code you need:
#!/usr/bin/env ruby
require "http"
HTTP.auth("Bearer YourMastodonAccessTokenGoesHere")
.post("https://ruby.social/api/v1/statuses", :params => {:status => "You can toot to Mastodon using the HTTP gem in TWO lines. I'm doing it right now"})
The reason I'm doing this is that my app needs basic functionality in terms of posting to Twitter and Mastodon, and the gems are a) overkill for that and b) the mastodon-api gem doesn't work with Ruby >= 2.7.
This will make my app MUCH simpler.
I ran into this problem yesterday (mastodon-api gem vs Ruby 2.7+) and it’s been fixed on the github HEAD, so it’ll work if you install from there.
(Now onward to getting gd2-ffij working on Raspbian.)
@suetanvil I had some success using the http gem. What I'm missing is a way to detect failure to post. I'll be working on that
I got some hints from this HTTP gem documentation
https://github.com/httprb/http/wiki/Authorization-Header