Skip to content

Instantly share code, notes, and snippets.

@Akkiesoft
Created December 6, 2017 15:24
Show Gist options
  • Save Akkiesoft/7e350c5c426a39f786f8fa4e82b4acac to your computer and use it in GitHub Desktop.
Save Akkiesoft/7e350c5c426a39f786f8fa4e82b4acac to your computer and use it in GitHub Desktop.
MastodonのストリーミングAPIを取得するサンプルスクリプト
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