Created
December 6, 2017 15:24
-
-
Save Akkiesoft/7e350c5c426a39f786f8fa4e82b4acac to your computer and use it in GitHub Desktop.
MastodonのストリーミングAPIを取得するサンプルスクリプト
This file contains hidden or 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
from mastodon import Mastodon, StreamListener | |
mstdn = Mastodon( | |
client_id = 'YOUR_CLIENT_ID', | |
client_secret = 'YOUR_CLIENT_SECRET', | |
api_base_url = 'https://social.mikutter.hachune.net' | |
) | |
mstdn.log_in( | |
username = 'YOUR_ENAIL', | |
password = 'YOUR_PASSWORD', | |
scopes=['read', 'write'], | |
) | |
class MaStreamListener(StreamListener): | |
def on_update(self, status): | |
print "HOGE" | |
def on_notification(self, notification): | |
print "FUGA" | |
def on_delete(self, status_id): | |
print "PIYO" | |
def handle_heartbeat(self): | |
print "PING-PONG" | |
mstdn.user_stream(MaStreamListener(), async=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment