Line bot 教學

Line bot 教學

帳號建立教學文章

https://miny.app/jvevx

Line 開發網址

https://developers.line.biz

建立完後 API 打法

Request Type:POST

Request URL:https://api.line.me/v2/bot/message/push

Headers設定:

Content-Type:application/json

Authorization:Bearer+(一個空字串)+(Channel Access Token)

Request:

{
    "to": "複製+貼上Channel Settings頁的Your user ID",
    "messages": [
        {
            "type": "text",
            "text": "Hello,Ting~這是Line Bot API測試訊息"
        },
        {
            "type": "sticker",
            "packageId": "1",
            "stickerId": "2"
        }
    ]
}


Line Notify(群組發放)

網址:https://notify-bot.line.me/

取得 code

https://notify-bot.line.me/oauth/authorize?response_type=code&client_id={
Client ID}&redirect_uri={Callback URL}&scope=notify&state=NO_STATE


選你要的群組

按下 Agree and connect 後會導入到之前填寫的 Callback URL。

http://localhost:4200/?code=xCNeyycIaVnp9BOF6ktL&state=NO_STATE

  • 可以從 request 取得 code

透過 postman 取得 token

  • method: post
  • url: https://notify-bot.line.me/oauth/token
  • Header
    • Content-Type: application/x-www-form-urlencoded
  • Body
    • code: 上一部取到的 code
    • client_id: 設定的 Client ID
    • client_secret: 設定的 Client Secret
    • redirect_uri: 設定的 Callback URL
    • grant_type: authorization_code

傳送訊息


留言

這個網誌中的熱門文章

數位信封 Digital Envelope

SSL的運作原理