LoginSignup
1
0

More than 5 years have passed since last update.

[LINE] デフォルトアクションとマルチアクションを試してみた

Posted at

前提

スクリーンショット 2018-05-25 午前10.59.47.png (192.0 kB)

Push Message API

HTTPリクエスト

リクエストヘッダー

  • Content-Type application/json
  • Authorization Bearer {channel access token}

説明

プロパティ タイプ 必須 説明
defaultAction アクションオブジェクト 任意 画像、タイトル、テキストの領域全体に対して設定できる、タップされたときのアクション

サンプル

curl
curl -X POST -H 'Content-Type:application/json' -H 'Authorization: Bearer {トークン}' -d '{
    "messages": [
        {
            "altText": "かご落ち商品",
            "template": {
                "columns": [
                    {
                        "actions": [
                            {
                                "label": "詳細はこちら▶︎",
                                "type": "uri",
                                "uri": "https://google.com"
                            }
                        ],
                        "defaultAction": {
                            "type": "uri",
                            "label": "defaultAction",
                            "uri": "http://yahoo.co.jp"
                        },
                        "text": "¥1000",
                        "thumbnailImageUrl": "http://sample.com",
                        "title": "サンプルタイトル"
                    }
                ],
                "type": "carousel"
            },
            "type": "template"
        }
    ],
    "to": "{LINEUserID}"
}' \https://api.line.me/v2/bot/message/push

イメージ画像

スクリーンショット 2018-07-11 午後7.19.12.png

defaultAction をクリックした場合に、Yahoo!のページに遷移

スクリーンショット 2018-07-11 午後7.21.58.png

通常のActionをクリックした場合に、googleのページに遷移

スクリーンショット 2018-07-11 午後7.22.26.png

マルチアクションについて

説明

  • 複数のアクションを指定することができる (最大3個まで)
  • カルーセルで複数配信した場合に、異なるアクション数では配信することは出来ない
プロパティ タイプ 必須 説明
actions アクションオブジェクトの配列 任意 タップされたときのアクション 最大件数:3

sample

curl -X POST -H 'Content-Type:application/json' -H 'Authorization: Bearer {トークン}' -d '{
    "messages": [
  {
            "type":"text",
            "text":"★カートに商品が残っています★\nお買い忘れはございませんか?"
        },
        {
            "altText": "かご落ち商品",
            "template": {
                "columns": [
                    {
                        "actions": [
                            {
                                "type": "uri",
                                "label": "商品詳細はこちら▶︎",
                                "uri": "https://www.sample.com"
                            },
                            {  
                               "type":"uri",
                               "label":"TOPはこちら▶︎",
                               "uri":"https://www.sample.com"
                            }
                        ],
                        "text": "¥886",
                        "thumbnailImageUrl": "https://www.sample.com",
                        "title": "マルチビタミン"
                    },
                    {
                        "actions": [
                            {
                                "type": "uri",
                                "label": "詳細はこちら2▶︎",
                                "uri": "https://www.sample.com"
                            },
                            {  
                               "type":"uri",
                               "label":"Buy2",
                               "uri":"https://www.sample.com"
                            }
                        ],
                        "text": "ビタミンサンプル",
                        "thumbnailImageUrl": "https://www.sample.com",
                        "title": "マルチビタミン"
                    }
                ],
                "type": "carousel"
            },
            "type": "template"
        }
    ],
    "to": "{LINEUserID}"
}' \https://api.line.me/v2/bot/message/push

イメージ画像

スクリーンショット 2018-07-11 午後7.20.40.png

1
0
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
1
0