Php Facebook messenger机器人通用模板不工作
我正在使用api.ai构建一个Facebook机器人,我需要使用Facebook通用模板发送响应。我从数据库中获取要列出的项目列表,并将它们放入一个数组中,然后分配给一个变量。我的问题是,数据实际上是按照Ngrok的显示返回的,但它没有作为通用模板显示在Facebook上。什么也看不出来。这是我的密码Php Facebook messenger机器人通用模板不工作,php,facebook,mysqli,facebook-messenger-bot,Php,Facebook,Mysqli,Facebook Messenger Bot,我正在使用api.ai构建一个Facebook机器人,我需要使用Facebook通用模板发送响应。我从数据库中获取要列出的项目列表,并将它们放入一个数组中,然后分配给一个变量。我的问题是,数据实际上是按照Ngrok的显示返回的,但它没有作为通用模板显示在Facebook上。什么也看不出来。这是我的密码 while($result = mysqli_fetch_assoc($res)){ $array[] = array(
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"=>[
//One attachment
$array
//First attachment ends
]
]
] ]
]
]);
echo $data;
}
我解决了。应该是:
"elements"=> $array