-
-
Save codeclinic/8fe8b3baec441ba1e55a80fce0f1c0ce to your computer and use it in GitHub Desktop.
Revisions
-
Alex Stone created this gist
Mar 3, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ <?php // (string) $message - message to be passed to Slack // (string) $room - room in which to write the message, too // (string) $icon - You can set up custom emoji icons to use with each message public static function slack($message, $room = "engineering", $icon = ":longbox:") { $room = ($room) ? $room : "engineering"; $data = "payload=" . json_encode(array( "channel" => "#{$room}", "text" => $message, "icon_emoji" => $icon )); // You can get your webhook endpoint from your Slack settings $ch = curl_init("WEBHOOK ENDPOINT GOES HERE"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); // Laravel-specific log writing method // Log::info("Sent to Slack: " . $message, array('context' => 'Notifications')); return $result; }