Skip to content

Instantly share code, notes, and snippets.

@mathieulesniak
Created September 2, 2015 12:43
Show Gist options
  • Save mathieulesniak/daf18563860db8cf09d7 to your computer and use it in GitHub Desktop.
Save mathieulesniak/daf18563860db8cf09d7 to your computer and use it in GitHub Desktop.
<?php
function postToSlack($message, $room, $fromName = null, $icon = null)
{
$data = json_encode(array(
"username" => $fromName,
"channel" => "#{$room}",
"text" => $message,
"icon_emoji" => $icon
)
);
$urlPoster = \Suricate\Suricate::Curl();
$urlPoster
->setUrl(SLACK_API_ENDPOINT)
->setMethod('POST');
$urlPoster->postFields = ['payload' => $data];
$urlPoster->send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment