Xを学んでみる(2)
Published:
X APIの無料アカウント申請
I want to create an X bot that automatically posts Web3-related topics on a regular basis, and also create a script that converts blog posts into X threads and posts them.
I also want to learn the X API by actually trying it out and seeing what kinds of things I can do with it.
プロジェクト設定
App設定
鍵を作成する
X BOT用のレポジトリを作成する
┌──(stardust✨stardust)-[~]
└─$ git clone git@github.com:stardustdotbox/X.git
Cloning into 'X'...
warning: You appear to have cloned an empty repository.
鍵をBOTに設定する
X_API_KEY=your_api_key_here
X_API_SECRET=your_api_secret_here
X_ACCESS_TOKEN=your_access_token_here
X_ACCESS_TOKEN_SECRET=your_access_token_secret_here
X_BEARER_TOKEN=your_bearer_token_here
XにHello Worldを投稿する
┌──(venv)(stardust✨stardust)-[~/X]
└─$ python hello_world.py
投稿中: Hello World
✅ 投稿成功!
ツイートID: 2008603481293418556
URL: https://x.com/i/web/status/2008603481293418556
びっくりしたこと
- ユーザにとって、そのポストが人間によって行われているのかBOTによって行われているのかを判断できるパラメータは現在、存在しない。(驚愕
参考文献
- https://github.com/stardustdotbox/X
- https://www.stardust.box/posts/2025/01/Learning-X-1/
- https://developer.x.com/en
- https://docs.x.com/x-api/introduction
- https://developer.twitter.com/en/portal/dashboard
ブログ更新コマンド
┌──(stardust✨stardust)-[~/stardustdotbox.github.io]
└─$ git add -A && git commit -m 'Xを学んでみる(2)' && git push
