Xを学んでみる(2)

less than 1 minute read

Published:

image

X APIの無料アカウント申請

image

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.

image

プロジェクト設定

image

App設定

image

鍵を作成する

image

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

image

びっくりしたこと

  • ユーザにとって、そのポストが人間によって行われているのか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

Tags: