使用軟體

postman:https://www.postman.com/

可以下載軟體,或是直接在網頁上編輯代碼

第一步、新增Richmenu

POSThttps://api.line.me/v2/bot/richmenu

※設定Name的時候,只能設定英文(小寫)、數字、符號-

Authorization

選擇Bearer Token

填入LINE@的Channel access token

※後續每個程式碼命令都要設定Authorization,只是我只有寫在第一個

Header

Key:Content-Type

Value:application/json

BODY

選擇raw,然後填入要發送的程式碼

第一層

{
  "size": {
    "width": 2500,
    "height": 1686
  },
  "selected": true,
  "name": "240814-01-a",
  "chatBarText": "撰寫文章",
  "areas": [
    {
      "bounds": {
        "x":1250 ,
        "y":0 ,
        "width":1250 ,
        "height":186 
      },
      "action": {
        "type": "richmenuswitch",
        "richMenuAliasId": "240814-01-b",
        "data": "240814-01-b"
      }
    },
    {
      "bounds": {
        "x":0 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "使用說明",
        "text": "/help"
      }
    },
    {
      "bounds": {
        "x":625 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/ula "
      }
    },
    {
      "bounds": {
        "x":1250 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/uba "
      }
    },
    {
      "bounds": {
        "x":1875 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/uts "
      }
    },  
    {
      "bounds": {
        "x":0 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/usg "
      }
    }, 
    {
      "bounds": {
        "x":625 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/ubo "
      }
    },
    {
      "bounds": {
        "x":1250 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/dtf "
      }
    },
    {
      "bounds": {
        "x":1875 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/plt "
      }
    },   
    {
      "bounds": {
        "x":0 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/ain "
      }
    },
    {
      "bounds": {
        "x":625 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/mar "
      }
    },
    {
      "bounds": {
        "x":1250 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/col "
      }
    },
    {
      "bounds": {
        "x":1875 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "postback",
        "label": "write",
        "data": "action=write",
        "inputOption": "openKeyboard",
        "fillInText": "/3yi "
      }
    }
  ]
}

第二層

{
  "size": {
    "width": 2500,
    "height": 1686
  },
  "selected": true,
  "name": "240814-01-b",
  "chatBarText": "文章完成",
  "areas": [
    {
      "bounds": {
        "x":0 ,
        "y":0 ,
        "width":1250 ,
        "height":186 
      },
      "action": {
        "type": "richmenuswitch",
        "richMenuAliasId": "240814-01-a",
        "data": "240814-01-a"
      }
    },
    {
      "bounds": {
        "x":0 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "使用說明",
        "text": "/help"
      }
    },
    {
      "bounds": {
        "x":625 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "ula完成",
        "text": "ula完成"
      }
    },
    {
      "bounds": {
        "x":1250 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "uba完成",
        "text": "uba完成"
      }
    },
    {
      "bounds": {
        "x":1875 ,
        "y":186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "uts完成",
        "text": "uts完成"
      }
    },  
    {
      "bounds": {
        "x":0 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "usg完成",
        "text": "usg完成"
      }
    }, 
    {
      "bounds": {
        "x":625 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "ubo完成",
        "text": "ubo完成"
      }
    },
    {
      "bounds": {
        "x":1250 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "dtf完成",
        "text": "dtf完成"
      }
    },
    {
      "bounds": {
        "x":1875 ,
        "y":686 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "plt完成",
        "text": "plt完成"
      }
    },   
    {
      "bounds": {
        "x":0 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "ain完成",
        "text": "ain完成"
      }
    },
    {
      "bounds": {
        "x":625 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "mar完成",
        "text": "mar完成"
      }
    },
    {
      "bounds": {
        "x":1250 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "col完成",
        "text": "col完成"
      }
    },
    {
      "bounds": {
        "x":1875 ,
        "y":1186 ,
        "width":625 ,
        "height":500 
      },
      "action": {
        "type": "message",
        "label": "3yi完成",
        "text": "3yi完成"
      }
    }
  ]
}

第二步、上傳圖片

POSThttps://api-data.line.me/v2/bot/richmenu/{richMenuId}/content

※要先上傳好圖片,才可以更新別名

Header

Key:Content-Type

Value:image/jpeg 或是 image/png 看你要上傳哪一種圖檔

Body

選擇binary,然後從電腦選擇圖片檔案,上傳至Postman的空間,再送出就可以上傳圖檔到Line Richmenu了

第三步、設定Richmeun別名

POSThttps://api.line.me/v2/bot/richmenu/alias/

※更新別名之前,要先上傳好圖片

Header

Key:Content-Type

Value:application/json

BODY

{
    "richMenuId": "ID",
    "richMenuAliasId": "別名"
}

第四步、設定預設的Richmeun

POSThttps://api.line.me/v2/bot/user/all/richmenu/{richMenuId}

基本上只要把{richMenuId}改成要設定為預設的Richmenu ID即可

最終結果

最後修改日期: 2025 年 1 月 23 日

作者