LoginSignup
4
3

More than 5 years have passed since last update.

chatwork API の使い方 (curl)

Last updated at Posted at 2018-11-21

chatwork へのメッセージの書き込みと、読み取りです。

API の仕様です。
エンドポイント: /rooms

書き込み
APIトークン と room_id は書き換えて下さい。

send_message.sh
#
#
#   send_message.sh
#
curl -X POST -H "X-ChatWorkToken: e12321ef233d8a92deb1cc15bc09b79e" \
    -d "body=こんにちは&self_unread=0" \
    "https://api.chatwork.com/v2/rooms/11111178/messages"

読み込み
APIトークン と room_id は書き換えて下さい。

get_message.sh
#
#   get_message.sh
#
curl -X GET -H "X-ChatWorkToken: e12321ef233d8a92deb1cc15bc09b79e" \
    "https://api.chatwork.com/v2/rooms/11111178/messages?force=1" > tmp01.json
#
jq . tmp01.json | less
#

メッセージの削除

delete_message.sh
#
#   delete_message.sh
#
URL="https://api.chatwork.com/v2/rooms/11111178/messages"
curl -X DELETE -H "X-ChatWorkToken: e12321ef233d8a92deb1cc15bc09b79e" \
    $URL"/1117025076764573696"
#
4
3
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
4
3