pimax / fb-messenger-php

Facebook Messenger Bot PHP API
GNU General Public License v2.0
314 stars 147 forks source link

Issue with the QuickReply implementation #86

Closed Yiidiir closed 7 years ago

Yiidiir commented 7 years ago

Couldn't implement the new added type of buttons/reply (with the MessageElement object) : QuickReply, the example file isn't updated neither.

wittfabian commented 7 years ago

Was ist deine Frage? Was genau machst du? Welche Fehler werden angezeigt?

Yiidiir commented 7 years ago

Nur fixiert! Scheint wie die QuickReplyButton Objekte erfordert eine Nutzlast (wir können nicht nur Text senden .. es sei denn, wir setzen '' als Parameter am Ende). This worked for me : $bot->send(new QuickReply($message['sender']['id'], 'TEXT ', [ new QuickReplyButton(QuickReplyButton::TYPE_TEXT, 'First button',' THIS PARAM is required, atleast put a whitespace!') ] ));

wittfabian commented 7 years ago

Should work

$bot->send(new StructuredMessage($message['sender']['id'],
                        StructuredMessage::TYPE_GENERIC,
                        [
                            'elements' => [
                                new MessageElement("First item", "Item description", "", [
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'),
                                    new MessageButton(MessageButton::TYPE_WEB, 'Web link', 'http://facebook.com')
                                ]),
                                new MessageElement("Second item", "Item description", "", [
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'),
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'Second button')
                                ]),
                                new MessageElement("Third item", "Item description", "", [
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'),
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'Second button')
                                ])
                            ]
                        ],
                        [ 
                            new QuickReplyButton(QuickReplyButton::TYPE_TEXT, 'First button', 'THIS PARAM is required, atleast put a whitespace!') 
                        ]
                    ));