Skip to content

Instantly share code, notes, and snippets.

@tplants
Created September 25, 2015 19:41
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 tplants/b0f0a80a45b8de57591f to your computer and use it in GitHub Desktop.
Save tplants/b0f0a80a45b8de57591f to your computer and use it in GitHub Desktop.
function slackIt($message, $channel) {
$ch = curl_init("https://annelewis.slack.com/services/hooks/slackbot");
$data = http_build_query([
"token" => "X0FDWx2MDDuwq26Esdcv4cqr",
"channel" => $channel, //"#mychannel",
"text" => $message, //"Hello, Foo-Bar channel message.",
"username" => "fabBot",
]);
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);
curl_close($ch);
return $result;
}
/*
function sendToSlack($message, $url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
$response_from_server = curl_exec($ch);
curl_close($ch);
echo "slack response: ";
print_r($response_from_server);
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment