Until Toot to Mastodon (Python)

Mastodon

It seems to be a Twitter-like service. Open Source. For the time being, until Toot (Tweet on Twitter) in Python.

Library

It seems that there are Python and Ruby, so I will do it with Python for the time being.

pip install Mastodon.py

registration

An instance (https://mastodon.nil.nu) has been created as a Japanese mackerel, so I will Toot there. Get an account on the instance.

from mastodon import Mastodon

Mastodon.create_app("yourapp", #client name
                    api_base_url = "https://mastodon.nil.nu", #Access destination
                    to_file = "yourapp_clientcred.txt" #Output destination file name
)

Login

from mastodon import Mastodon

mastodon = Mastodon(
    client_id="yourapp_clientcred.txt", #The guy made by registration
    api_base_url = "https://mastodon.nil.nu")

mastodon.log_in(
    "[email protected]", # ID(Registered e-mail address)
    "xxxx", # password
    to_file = "your_usercred.txt") #Output destination file name

Toot

from mastodon import Mastodon

mastodon = Mastodon(
    client_id="yourapp_clientcred.txt", #The guy made by registration
    access_token="your_usercred.txt", #The one made by logging in
    api_base_url = "https://mastodon.nil.nu")
mastodon.toot("Your message")

Someone make a client.

Recommended Posts

Until Toot to Mastodon (Python)
"Backport" to python 2
How to install Python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Rewrite Python2 code to Python3 (2to3)
How to install python
python decorator to retry
Introduction to Python language
Introduction to OpenCV (python)-(2)
Note to daemonize python
Introducing Python 2.7 to CentOS 6.6
[Python MinMaxScaler] Normalize to 0 ~ 1
[2020.8 latest] How to install Python
[python] Convert date to string
Post from Python to Slack
Post to vim → Python → Slack
Introduction to Python Django (2) Win
To flush stdout in Python
Convert numpy int64 to python int
python3: How to use bottle (2)
[Python] Convert list to Pandas [Pandas]
Cheating from PHP to Python
A road to intermediate Python
Python notes to forget soon
Create a Mastodon bot with a function to automatically reply with Python
[Python] How to use list 1
Login to website in Python
Connect to Wikipedia with Python
How to update Python Tkinter to 8.6
Post to slack with Python 3
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Post to Twitter using Python
How to use Python argparse
Start to Selenium using python
Update python on Mac to 3.7-> 3.8
3 Reasons Beginners to Start Python
Convert Scratch project to Python
[Python] Convert Shift_JIS to UTF-8
Python: How to use pydub
[Python] How to use checkio
Switch from python2.7 to python3.6 (centos7)
How to run Notepad ++ Python
Speech to speech in python [text to speech]
[Python] Another way to import
Connect to sqlite from python
Switch python to 2.7 with alternatives
Write to csv with Python
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
How to change Python version
An introduction to Python Programming
How to develop in Python
~ Tips for beginners to Python ③ ~
[python] How to judge scalar
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
Introduction to Python For, While
python3: How to use bottle (3)
python3: How to use bottle