Giter Site home page Giter Site logo

Comments (3)

avinashseth avatar avinashseth commented on September 26, 2024

How to handle payload?

First of all get the payload value

I prefer without foreach and switch statement

$special_command = $input['entry'][0]['messaging'][0]['postback']['payload'];

now do something like this

if(!empty($special_command)) { $bot->send(new Message($sender, 'You said ' . $special_command)); // or if($special_command === 'unique_payload_text_for_button_a') { // do the required } else if($special_command === 'unique_payload_text_for_button_b') { // do the required } else if($special_command === 'unique_payload_text_for_button_c') { // do the required } }

I guess i missed the doc and here how you have to set the payload text

$bot->send(new StructuredMessage($message['sender']['id'], StructuredMessage::TYPE_BUTTON, [ 'text' => 'Choose category', 'buttons' => [ new MessageButton(MessageButton::TYPE_POSTBACK, 'A Button','unique_payload_text_for_button_a'), new MessageButton(MessageButton::TYPE_POSTBACK, 'B button','unique_payload_text_for_button_b'), new MessageButton(MessageButton::TYPE_POSTBACK, 'unique_payload_text_for_button_c') ] ] ));

** here is how you have to handle them **

`
// from above

`

what is payload
payload is just like html id, works same, nothing special but has to be unique for every button or where ever you are using

hope this helps anyone who had this issue, i learned this in 3 days so you don't have to :)

sorry for the formatting issue

from fb-messenger-php-example.

vetrivelbright avatar vetrivelbright commented on September 26, 2024

hi can you post full code using php? last 2 days i am searching i am not able find working code.
my stackoverflow link
https://stackoverflow.com/questions/44364061/how-to-get-postback-button-value-in-the-callback-url-in-facebook-messenger-bot

from fb-messenger-php-example.

wittfabian avatar wittfabian commented on September 26, 2024

Open a new issue with an detailed problem description!

from fb-messenger-php-example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.