8
6

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 5 years have passed since last update.

Line Botでブロードキャストメッセージを使って友達全員にメッセージを一斉送信した。

Posted at

はじめに

Line Botで友達全員にメッセージを送るときにブロードキャストメッセージを使うと簡単にできたのでメモ。

送信方法

Google App Scriptを使用。
__CHANNEL ACCESS TOKEN__をLine Botのアクセストークンに置き換えてください。

const token = 'CHANNEL ACCESS TOKEN';

function broadcast() {
  UrlFetchApp.fetch('https://api.line.me/v2/bot/message/broadcast', {
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer ' + token,
    },
    payload: JSON.stringify({
      messages: [
        {
            type: 'text',
            text: 'メッセージ1'
        },
        {
            type: 'text',
            text: 'メッセージ2',
        }
      ]
    }),
  });
}

実行結果

LineCap.jpg

参考

8
6
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
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?