3
1

AT Protocol 覚書

Posted at

面白いおもちゃが急に出てきたので調べ事を雑に残しておく
apiを使うのに面倒な手順も(今は)不要だしapi利用制限も緩そうなので暇なときに遊ぼう
※気が向いたら綺麗に書き直す

from atproto import Client
from atproto_client.models.app.bsky.feed.get_timeline import Response

client = Client()
client.login('{メールアドレス or ユーザ名}', '{パスワード}')

# 普通の投稿
client.send_post(text='postテスト')

# 画像付き投稿
with open('test.jpg', 'rb') as f:
    img_data = f.read()

client.send_image(text='画像付きpostテスト', image=img_data, image_alt='test')

# タイムライン取得
res: Response = client.get_timeline()

print('ユーザ名:' + res.feed[0].post.author.display_name)
print('投稿時間:' + res.feed[0].post.record.created_at)
print('ポスト:' + res.feed[0].post.record.text)
print('いいね回数:' + str(res.feed[0].post.like_count))
print('リプライ回数:' + str(res.feed[0].post.reply_count))
print('リポスト回数:' + str(res.feed[0].post.repost_count))

超基本的なことは出来たので次は画像の取得周りをこねこねしてみよう

参考:https://atproto.blue/en/latest/

3
1
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
3
1