Instantly share code, notes, and snippets.

Embed
What would you like to do?
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