Facebook Messenger通用模板

时间:2018-06-20 02:22:50

标签: php laravel facebook

我正在使用dialogflow,并将dialogflow API获取到Messenger,但即使我遵循https://developers.facebook.com/docs/messenger-platform/send-messages/template/generic格式,也无法在Messenger API(facebook)中使用。我做错了什么吗?

    $FieldName = $fulfillmentMessage->getCard()
            {
                $title = $FieldName->getTitle();
                $subtitle = $FieldName->getSubtitle();
                $image_uri = $FieldName->getImageURI();
                $buttons = $FieldName->getButtons();
                foreach($buttons as $button)
                {
                    $text = $button->getText();
                    $postback = $button->getPostback();
                }
                $res = [
                    "recipient" => ["id" => $id],
                    'source' => "source",
                    'data' => ["facebook" => ["attachment" => ["type" => "template", "payload" => ['template_type' => "generic",
                    "elements" =>["title" => $title,
                    "image_url" => $image_uri,
                    "subtitle" => $subtitle,
                    "buttons" => [[
                    "type" => "web_url",
                    "url" => $postback,
                    "title" => $text],
                    ["type" => "postback",
                    "title" => $text,
                    "payload" =>$text]
                    ]]]]]]];
                $this->sendMessage($res);

0 个答案:

没有答案