Created
April 24, 2017 22:08
-
-
Save mmuoDev/5249df327e03a36395a4a29be41f565d to your computer and use it in GitHub Desktop.
Snippet of code that is supposed to return generic list of items for Facebook messenger bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while($result = mysqli_fetch_assoc($res)){ | |
$array[] = array( | |
"title"=> $result['title'], | |
"image_url"=> $result['img_url'], | |
"subtitle"=> "See all our colors", | |
"buttons"=>[ | |
[ | |
"type"=>"postback", | |
"title"=>$result['title'], | |
"payload"=>$result['payload_id'] | |
] | |
] | |
); | |
} | |
if ($intentName == "sex"){ | |
$data =json_encode([ | |
'speech' => "Hi ".$firstname, | |
'displayText' => "test", | |
'source' => "source", | |
'data' => ["facebook" => [ | |
"attachment"=>[ | |
"type"=>"template", | |
"payload"=>[ | |
"template_type"=>"generic", | |
"elements"=>[ | |
$array | |
] | |
] | |
] ] | |
] | |
]); | |
echo $data; | |
} |
Author
mmuoDev
commented
Apr 24, 2017
Try $element => $array
Thanks man
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment