Skip to content

Instantly share code, notes, and snippets.

@mmuoDev
Created April 24, 2017 22:08
Show Gist options
  • Save mmuoDev/5249df327e03a36395a4a29be41f565d to your computer and use it in GitHub Desktop.
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
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;
}
@mmuoDev
Copy link
Author

mmuoDev commented Apr 24, 2017

Thanks man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment