Skip to content

Instantly share code, notes, and snippets.

@rbocchinfuso
Created August 24, 2018 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbocchinfuso/0c94211cc641a2bfd9f0445f9660b94b to your computer and use it in GitHub Desktop.
Save rbocchinfuso/0c94211cc641a2bfd9f0445f9660b94b to your computer and use it in GitHub Desktop.
PHP Slack CURL Post Snippet
// post message
$message = "@$username is working on $text";
$data = "payload=" . json_encode(array(
'response_type' => $response_type,
"text" => $message,
"icon_emoji" => $icon
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SLACK_WEBHOOK);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
// var_dump($result);
if($result === false) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
// send ephemeral notification let user know that thier
echo "@$username you've let everyone on #the-railroad know you are working on $text";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment