Created
May 7, 2018 20:59
-
-
Save mtruitt/a57216b62eaced4365147d8ef97a07e7 to your computer and use it in GitHub Desktop.
Send via Slack Webhook
This file contains 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 characters
<?php | |
$message = array( 'text' => 'This is a test message via slack and curl' ); | |
$data_message = json_encode( $message ); | |
$ch = curl_init( 'slack webhook goes here' ); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_message); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($data_message)) | |
); | |
$result = curl_exec($ch); | |
curl_close($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment