4
3

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.

(入門) LINE Developersに登録してプッシュメッセージ送信してみた

Last updated at Posted at 2021-02-08

コンソール

  • Channel ID
  • Channel secret

をメモっておく。

短期のチャネルアクセストークンを取得

get_access_token.sh
CHANNEL_ID="0000000000"
CHANNEL_SECRET="ffffffffffffffffffffffffffffffff"

curl -v -X POST https://api.line.me/v2/oauth/accessToken \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode "client_id=${CHANNEL_ID}" \
--data-urlencode "client_secret=${CHANNEL_SECRET}"

プッシュメッセージ

  • 1人以上のユーザーに同時に送信する。
  • TOKEN値は上で取得したものを設定。
  • TOは、今は自分のID以外知らないので、テストで自分のUserIDを指定。

2.png

TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

curl -v -X POST https://api.line.me/v2/bot/message/multicast \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" \
-d '{
    "to": ["Uffffffffffffffffffffffffffffffff"],
    "messages":[
        {
            "type":"text",
            "text":"Hello, world3"
        },
        {
            "type":"text",
            "text":"Hello, world4"
        }
    ]
}'

DB57E687-AD53-4DF3-95C7-57B3D114C44A.jpeg

その他リンク

LINE 公式アカウントログイン

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?