Created
November 15, 2022 11:54
-
-
Save andypiper/c2b0915d7439014d01f9cce0753ec370 to your computer and use it in GitHub Desktop.
Post a Toot from MicroPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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