LoginSignup
25
23

More than 5 years have passed since last update.

MastodonにTootするまで(Python)

Posted at

Mastodon

Twitterライクなサービスらしい。オープンソース。
とりあえずPythonでToot(TwitterでいうTweet)するまで。

ライブラリ

PythonとかRubyとかあるらしいので、とりあえずPythonでやります。

pip install Mastodon.py

レジストレーション

日本鯖としてインスタンス(https://mastodon.nil.nu) ができたのでそこにTootします。インスタンスでアカウントは取得しておく。

from mastodon import Mastodon

Mastodon.create_app("yourapp", # クライアント名
                    api_base_url = "https://mastodon.nil.nu", # アクセス先
                    to_file = "yourapp_clientcred.txt" # 出力先ファイル名
)

ログイン

from mastodon import Mastodon

mastodon = Mastodon(
    client_id="yourapp_clientcred.txt", # レジストレーションでできたやつ
    api_base_url = "https://mastodon.nil.nu")

mastodon.log_in(
    "xxxx@xxxxxxxx.xxx", # ID(登録メールアドレス)
    "xxxx", # password
    to_file = "your_usercred.txt") # 出力先ファイル名

Toot

from mastodon import Mastodon

mastodon = Mastodon(
    client_id="yourapp_clientcred.txt", # レジストレーションでできたやつ 
    access_token="your_usercred.txt", # ログインでできたやつ
    api_base_url = "https://mastodon.nil.nu")
mastodon.toot("Your message")

だれかクライアントつくって。

25
23
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
23