From: Maurizio Paglia Date: Wed, 16 Nov 2022 13:37:12 +0000 (+0100) Subject: Update pelican_toot.py X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=66ed83de2d15a3bdc9624e2796cfbb5873e03bfe;p=blog.git Update pelican_toot.py --- diff --git a/pelican_toot.py b/pelican_toot.py index c402be38..a1bcb1fa 100644 --- a/pelican_toot.py +++ b/pelican_toot.py @@ -11,4 +11,34 @@ logger = logging.getLogger(__name__) from pelican import signals # https://github.com/halcy/Mastodon.py + +# Copied from Mastodon.py readme - fix it!! +# Register your app! This only needs to be done once. Uncomment the code and substitute in your information. + +from mastodon import Mastodon + +''' +Mastodon.create_app( + 'pytooterapp', + api_base_url = 'https://mastodon.social', + to_file = 'pytooter_clientcred.secret' +) +''' + +# Then login. This can be done every time, or use persisted. + from mastodon import Mastodon + +mastodon = Mastodon(client_id = 'pytooter_clientcred.secret') +mastodon.log_in( + 'my_login_email@example.com', + 'incrediblygoodpassword', + to_file = 'pytooter_usercred.secret' +) + +# To post, create an actual API instance. + +from mastodon import Mastodon + +mastodon = Mastodon(access_token = 'pytooter_usercred.secret') +mastodon.toot('Tooting from Python using #mastodonpy !')