xurl 是做什麼的?
X API 官方命令列工具。
主要上游:https://github.com/xdevplatform/xurl
安裝
Homebrew:
brew install --cask xdevplatform/tap/xurl
npm:
npm install -g @xdevplatform/xurl
Shell 腳本:
curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | bash
Go:
go install github.com/xdevplatform/xurl@latest
安全
- 切勿讀取、列印、摘要、上傳或將
~/.xurl內容貼入 LLM 上下文。 - 切勿要求使用者將客戶端密碼、Bearer 令牌或 OAuth 令牌貼入對話。
- 在代理運行中切勿使用
--verbose;它可能暴露認證標頭。 - 不要在代理對話中使用內嵌密碼參數執行認證命令。
- 使用者必須在代理對話之外的本機機器上手動註冊應用程式憑證。
認證
檢查目前狀態:
xurl auth status
若應用程式已註冊,完成 OAuth 2.0:
xurl auth oauth2
多應用程式:
xurl auth apps list
xurl auth default my-app
xurl auth default my-app alice
xurl --app dev-app /2/users/me
注意事項:
xurl將應用程式配置和令牌儲存在~/.xurl。- X 開發者入口網站中的 OAuth 2.0 重新導向 URI 應設為
http://localhost:8080/callback。 - 此處刻意省略內嵌密碼的應用程式註冊範例。請在代理對話之外執行該操作。
常用快捷指令
xurl post "Hello world!"
xurl reply 1234567890 "Nice post"
xurl quote 1234567890 "My take"
xurl delete 1234567890
xurl read 1234567890
xurl search "from:elonmusk" -n 10
xurl whoami
xurl user @XDevelopers
xurl timeline -n 20
xurl mentions -n 10
xurl like 1234567890
xurl unlike 1234567890
xurl repost 1234567890
xurl unrepost 1234567890
xurl bookmark 1234567890
xurl unbookmark 1234567890
xurl bookmarks -n 10
xurl likes -n 10
xurl follow @handle
xurl unfollow @handle
xurl following -n 20
xurl followers -n 20
xurl dm @handle "message"
xurl dms -n 10
xurl media upload path/to/file.mp4
xurl media status MEDIA_ID
POST_ID 也可以是完整的 X 狀態 URL。
原始端點模式
GET:
xurl /2/users/me
POST JSON:
xurl -X POST /2/tweets -d '{"text":"Hello world!"}'
標頭:
xurl -H "Content-Type: application/json" /2/tweets
選擇認證類型:
xurl --auth oauth2 /2/users/me
xurl --auth oauth1 /2/tweets
xurl --auth app /2/users/me
選擇 OAuth2 帳號:
xurl --username alice /2/users/me
串流:
xurl /2/tweets/search/stream
xurl -s /2/users/me
快速檢查
安裝:
xurl version
認證:
xurl auth status
認證後的即時請求:
xurl whoami