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.

Postman使ってLINEリッチメニュー作成する

Last updated at Posted at 2021-01-21

ここでPOSTMANを使ってLINEリッチメニューを作成する方法を見てみましょう:relaxed:

リッチメニューというのはLINE公式アカウントのトーク画面に表示される、カスタマイズ可能なメニューです。

リッチメニューを表示するには、リッチメニューの画像をアップロードし、さらにデフォルトのリッチメニューを設定するかリッチメニューをユーザーとリンクする必要があります。

先に、以下のリンクをクリックしてPOSTMANをダウンロードしてインストールしましょう
https://www.postman.com/downloads/

リッチメニュー作成

1. POSTMANを開いて新しいタブを開きます。 2. 送信方法をPOSTにします。 3. URL欄にLINEリッチメニュー作成するエンドポイントを入力してください。
https://api.line.me/v2/bot/richmenu 4. POSTMANのAutherizationタブを開いてTypeからBearer Tokenを選択してください、 5. 右側のToken欄に自分のチャネルのアクセストークンを入れてください。 ![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1037342/12a61e43-a0df-c6e7-11ab-a61386493c3a.png) 6.Headersタブを開いてKeyはContent-TypeとValueはapplication/jsonに設定してください。 ![2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1037342/87338e38-9fc7-6239-318b-4c3f70ff1397.png) 7.次はBodyタブを開いてオプションからrawを選択してテキストボックスに自分のリッチメニューの設定を入力します。(https://developers.line.biz/ja/reference/messaging-api/#create-rich-menu参考にしてください)

例:


{
  "size": {
    "width": 2500,
    "height": 1686
  },
  "selected": false,
  "name": "Nice richmenu",
  "chatBarText": "Tap to open",
  "areas": [
    {
      "bounds": {
        "x": 0,
        "y": 0,
        "width": 2500,
        "height": 1686
      },
      "action": {
        "type": "postback",
        "data": "action=buy&itemid=123"
      }
    }
  ]
}

3.JPG
8.これで設定は完了なので送信ボタンを押します。
9.レスポンスは以下の通りであれば完成です。:relaxed:
4.png

リッチメニューの画像をアップロードする

1.作成と同じく以下の情報でPOSTを作成します。 送信方法-POST エンドポイント - https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content {richMenuId}は前送られてきたレスポンスのrichMenuIdです。 ![5.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1037342/a8d492c2-8463-2e2b-a4b4-e0d3c70b4f4c.png) Content-Typeはimage/jpeg、image/pngのように自分の画像の拡張子で設定してください。(image/xxxx) Bodyタブからbinaryを選択してファイルから自分の画像を選択してください。 ![6.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1037342/9117dec9-0af6-a883-69f2-cf159e22454a.jpeg) 設定終了なので送信ボタンを押してください。 レスポンスのステータスは200 okとbodyは空であればokです。 ![7.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1037342/5c3f4765-3659-74d6-c8f8-79afea082555.jpeg)

補足

デフォルトのリッチメニューを設定する
送信方法:POST
エンドピント:https://api.line.me/v2/bot/user/all/richmenu/{richMenuId}
Authorization:Bearer {channel access token}

リッチメニューを削除する
送信方法:DELETE
エンドピント:https://api.line.me/v2/bot/richmenu/{richMenuId}
Authorization:Bearer {channel access token}

デフォルトのリッチメニューのIDを取得する
送信方法:GET
エンドピント:https://api.line.me/v2/bot/user/all/richmenu
Authorization:Bearer {channel access token}

リッチメニューの画像をダウンロードする
送信方法:GET
エンドピント:https://api-data.line.me/v2/bot/richmenu/{richMenuId}/content
Authorization:Bearer {channel access token}

リッチメニューの配列を取得する
送信方法:GET
エンドピント:https://api.line.me/v2/bot/richmenu/list
Authorization:Bearer {channel access token}

デフォルトのリッチメニューを解除する
送信方法:DELETE
エンドピント:https://api.line.me/v2/bot/user/all/richmenu
Authorization:Bearer {channel access token}

リッチメニューとユーザーをリンクする
送信方法:POST
エンドピント:https://api.line.me/v2/bot/user/{userId}/richmenu/{richMenuId}
Authorization:Bearer {channel access token}

ユーザーのリッチメニューのIDを取得する
送信方法:GET
エンドピント:https://api.line.me/v2/bot/user/{userId}/richmenu
Authorization:Bearer {channel access token}

リッチメニューとユーザーのリンクを解除する
送信方法:DELETE
エンドピント:https://api.line.me/v2/bot/user/{userId}/richmenu
Authorization:Bearer {channel access token}

リッチメニューと複数のユーザーをリンクする
送信方法:POST
エンドピント:https://api.line.me/v2/bot/richmenu/bulk/link
Authorization:Bearer {channel access token}
Content-Type:application/json
body:


'{
  "richMenuId":"{richMenuId}",
  "userIds":["{userId1}","{userId2}"]
}'

複数のユーザーのリッチメニューのリンクを解除する
送信方法:POST
エンドピント:https://api.line.me/v2/bot/richmenu/bulk/unlink
Authorization:Bearer {channel access token}
Content-Type:application/json
body:


'{
  "userIds":["{userId1}","{userId2}"]
}'
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?