Send JSON from a slash command using PHP -


i have created slash command slack , need send json data slack. code using response treated plain text slack.

$data = "payload=" . json_encode(array(                     "content-type"  =>  "application/json",                     "text"          =>  "a message",                     "response_type" =>  "ephemeral",                     "username"      =>  "user",                     "icon_emoji"    =>  ":icon:"                         ),json_unescaped_slashes);  echo $data; 

am missing something?

it seems wasn't building json file according slack conventions. should not have payload parameter used incoming web hooks. php page should include line: header('content-type: application/json');

the slash command response should built follows:

$data = json_encode(array(                 "content-type"  =>  "application/json",                 "text"          =>  "a message",                 "response_type" =>  "ephemeral",                 "username"      =>  "user",                 "icon_emoji"    =>  ":icon:"                     ),json_unescaped_slashes); 

echo $data;


Comments