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

Qiitaのアクセス数取得自動化 Chatwork編②

0
Posted at

データ連携に奮闘中の皆様、いかがお過ごしでしょうか。

皆様、APIのドキュメント読むのはお好きですか。
APIのドキュメントを読んで、必要な情報をGETしなくてはなりませぬ。

↓以下は、サンプルリクエスト。

curl --request POST \
     --url https://api.chatwork.com/v2/rooms/room_id/messages \
     --header 'accept: application/json' \
     --header 'content-type: application/x-www-form-urlencoded' \
     --data self_unread=0

順番に例を見ながら確認していきましょう。
・使うのは、「POST」
・urlのroom_idは、投稿したいチャットのルームID。
・bodyのところに通知メッセージを入れれば良さそうです。

ルームIDは、該当チャットのURLの「rid」以降の文字
image.png

↓できあがりはこちら。

curl --request POST --url https://api.chatwork.com/v2/rooms/437520158/messages --header "accept: application/json" --header "content-type: application/x-www-form-urlencoded" --header "x-chatworktoken: <APIトークン>" --data "self_unread=0" --data "body=hello" --ssl-no-revoke

早速試してみたところ、「message id」が返却されました。
image.png

該当のChatworkのルームを確認すると、メッセージが投稿されています:star:
image.png

これで同じように、HULFTSquareのRESTからPOSTすれば、Chatworkに通知できそうです。

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