1

I'm working on a slack integration module where users of a Slack Team can post message in a Slack Channel via 'chat.postMessage' API. When an user posting a message every time it's showing the sender name who created the channel. How to show the actual sender name?

Here is my cURL Code,

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://slack.com/api/chat.postMessage',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "channel": "C03T3JT2SRF",
    "text": "Hello Slack"
  }',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer token'
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
Sourav Das
  • 527
  • 2
  • 5
  • 13

0 Answers0