Home>

I'm studying messaging api, but in the action = "begin&res = yes" part of the data of actions below, get begin when I want to get action, get yes when I want to get res. I want to do this, but for some reason my code results in action ='action' and res ='res'.
* Addition
In the second one I wrote, I want to get it like action ='begin', res = "yes" or "no".
If i get it by the method written at the end, the character string will be taken as it is for some reason as action ='action', res ='res'.
Can't you get action ='begin', res = "yes" or "no" somehow?

message = {
                        "type": "template",
                        "altText": "this is a confirm template",
                        "template": {
                            "type": "confirm",
                            "text": "Are you sure?",
                            "actions": [
                                {
                                    "type": "postback",
                                    "label": "yes",
                                    "data": "action = begin&res = yes"
                                },
                                {
                                    "type": "postback",
                                    "label": "No",
                                    "text": "no",
                                    "data": "action = begin&res = no"
                                }
                            ]
                        }
                    }
{"events" =>[{"type" =>"postback", "replyToken" =>"hoge", "source" =>{"userId" =>"hoge", "type" =>"user"} , "timestamp" =>1606388380238, "mode" =>"active", "postback" =>{"data" =>"action = begin&res = yes"}}],
"destination" =>"hoge", "linebot" =>{"events" =>[{"type" =>"postback", "replyToken" =>"hoge", "source" =>{"userId" = >"hoge", "type" =>"user"}, "timestamp" =>1606388380238, "mode" =>"active", "postback" =>{"data" =>"action = begin&res = yes"} }], "destination" =>"hoge"}}
events.each do | event |
# ~~~~ Omitted ~~~~
action = event ['postback'] ['data'] ['action'] # This will get'action' instead of'begin'
res = event ['postback'] ['data'] ['res'] # This will get'res' instead of'yes'