2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

curlでChatworkの投稿を削除するワンライナー

Last updated at Posted at 2020-09-08

TOKEN_IDはAPIのトークンを、ROOM_IDは削除したい投稿のあるルームIDを、MESSAGE_IDには投稿のIDにそれぞれ置き換えてください。

sh
curl -X DELETE  -H "X-ChatWorkToken: TOKEN_ID" "https://api.chatwork.com/v2/rooms/ROOM_ID/messages/MESSAGE_ID"
PowerShell
Invoke-RestMethod -Uri "https://api.chatwork.com/v2/rooms/ROOM_ID/messages/MESSAGE_ID" -Method DELETE -Headers @{"X-ChatWorkToken" = TOKEN_ID}

任意の投稿の「リンク」ボタンをクリックしたときに投稿記入欄に表示されるURLのうち、ハイフンの左側の数列がROOM_IDで、ハイフンの右側の数列がMESSAGE_IDになります。

# ROOM_IDは 123456789
# MESSAGE_IDは 1234567890123456789
https://www.chatwork.com/#!rid123456789-1234567890123456789

ひとこと

このワンライナーをシェルスクリプトに組み込んでおけば、ボットの投稿削除のためにわざわざボットアカウントでログインする必要がなくなりますね!

参考リンク:

APIトークンを発行する – ヘルプ | Chatwork

2
0
0

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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?