- 用戶登記並取得 code
- 使用第一步取得的 code 拿取權杖(Access Token)
- 利用權杖(Access Token)發送文字訊息
使用 LINE 帳號登入成功後右上角點選進入管理登入服務,再來點選登入服務來建立你的服務。
由於目前在本機端測試所以可以先隨意填寫 localhost 端口

- 網址夾帶參數取得 LINE Notify 授權
- response_type
- client_id
- redirect_uri
- state
<!DOCTYPE html><htmllang="tw"><head><title></title><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1"><script>functionLineNotify(){varURL='https://notify-bot.line.me/oauth/authorize?';URL+='response_type=code';URL+='&client_id=[YOUR_CLIENT_ID]';URL+='&redirect_uri=[YOUR_CALLBACK_URL]';URL+='&scope=notify';URL+='&state=NO_STATE';window.location.href=URL;}</script></head><body><buttononclick="LineNotify();"> 啟用 LineNotify </button></body></html>完成後就能開啟網頁點擊按鈕取得 Line Notify code 囉!
把網址列上所回傳的 code 記住我們之後會拿他來取得權杖(Access Token)。接下來我們使用 Postman 來模擬 POST 取得權杖。
[POST] https://notify-bot.line.me/oauth/token
Body(form-data)
| key | value |
|---|---|
| code | lkaywNuEiYPpfrcVyBCEMg |
| grant_type | authorization_code |
| redirect_uri | http://localhost:3000/ |
| client_id | YOUR CLIENT ID |
| client_secret | YOUR CLIENT SECRET |
取得權杖後就能拿他還傳送訊息囉!
[POST] https://notify-api.line.me/api/notify
Headers
| key | value |
|---|---|
| Authorization | Bearer AWHwIf7TzisK019h0m9UVSnEz2nfRTxmQB4edrgFvWz |
Body(form-data)
| key | value |
|---|---|
| message | Hello! |








