chiark / gitweb /
Update pelican_toot.py
authorMaurizio Paglia <mpaglia0@gmail.com>
Wed, 16 Nov 2022 13:37:12 +0000 (14:37 +0100)
committerGitHub <noreply@github.com>
Wed, 16 Nov 2022 13:37:12 +0000 (14:37 +0100)
pelican_toot.py

index c402be382dff9580c08a1fd02032479c4c95b70c..a1bcb1fa705e044011c590e8bd7b68cd85597c88 100644 (file)
@@ -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 !')