Search code examples
phpcurlwebhooksslackslack-api

An unwanted emoji is showing up in Slack messages sent through to webhook


I've searched everywhere to find someone else with this issue but couldn't find anything.

The issue is I am trying to send a message from a php script to my slack channel with the Shopify order number. It's working as it should apart from one thing, It's adding a Red Square emoji in the messages and I can't figure out why.

This is what the message comes through as:

red square that shouldn't be there

And this is the code I'm using to send the slack message:

  // Create a constant to store your Slack URL
  define('SLACK_WEBHOOK', 'https://hooks.slack.com/services/x/x/eActr8MIhT0SIyKuGGwR0ScU');
  // Make your message
  $message = array('payload' => json_encode(array('text' => 'Order '.$shopify_order['name'].' has been sent to Embroidery Works' )));
  // Use curl to send your message
  $c = curl_init(SLACK_WEBHOOK);
  curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($c, CURLOPT_POST, true);
  curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($c, CURLOPT_POSTFIELDS, $message);
  curl_exec($c);
  curl_close($c);

Solution

  • Worth nothing: #BA1242 is a dark-red color. You'll often see it on programmer forums when describing CSS. color-hex.com/color/ba1242 – @Chris

    Slack automatically posts previews of hex colours as Chris (Thanks!) pointed out. Just turns out that this particular store codes match hex colors.