Dec 01, 2022 04:51 PM
I am adding Mastodon as an end point for my social needs.
I would like to replicate my Twitter automations and post to Mastodon. Does anyone have any idea how to create a webhook to do that?
Dec 05, 2022 02:23 PM
I think this should be possible with an automation!
You can make a POST request to the Mastodon API using the Run Script action in an automation. Here's the documentation for the fetch() method.
Dec 30, 2022 06:56 PM
I wish I was smart enough to figure this out. Would you mind giving me a sample of the script with this dummy Mastodon status update code?
# Set up
Mastodon mastodon = Mastodon( access_token = 'token.secret', api_base_url = 'https://botsin.space/' ) mastodon.status_post("hello world!")
Mar 09, 2023 08:00 AM
Autumn I wanted to follow up with this and see if you would be able to send me an example of the script. I am not a coder and that is where I fall short.
Jun 06, 2023 09:43 PM
Hey Jason! It looks like I didn't have notifications turned on for replies on here. Sure I can totally share some sample code:
let newStatusToPost = 'Hello World!'
let response = await fetch('https://mastodon.social/api/v1/statuses', {
method: 'POST',
body: JSON.stringify({status: newStatusToPost}),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_MASTODON_ACCESS_TOKEN'
},
});
You'll need to change the mastodon.social part of the url to whatever the url for the mastodon you're posting to is. (that's probably not the right term for it, but I'm not very familiar with mastodon terminology)