Skip to content

Instantly share code, notes, and snippets.

@andypiper
Created November 15, 2022 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andypiper/c2b0915d7439014d01f9cce0753ec370 to your computer and use it in GitHub Desktop.
Save andypiper/c2b0915d7439014d01f9cce0753ec370 to your computer and use it in GitHub Desktop.
Post a Toot from MicroPython
import network
import urequests
import ujson
# do_connect()
mast_url="https://mastodon.social"
token=MY_MASTODON_TOKEN
# note: this *must* include content-type
header = {'Authorization': 'Bearer {}'.format(token), 'content-type': 'application/json'}
toot = {'status': 'another test', 'visibility': 'unlisted'}
postURL = mast_url +'{}'.format('/api/v1/statuses')
r = urequests.post(postURL, data=ujson.dumps(toot), headers=header)
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment