Last active
February 12, 2020 08:21
-
-
Save sagistrauss/ce9bac2e9502996e232ae8b146be73fb to your computer and use it in GitHub Desktop.
Create a Mixpanel webhook to any event and get notified in slack. Replace with your own token. Was built as part of https://findthat.email marketing automation.
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 | |
$event = json_decode($_POST, true) | |
public static function slack($message, $channel) | |
{ | |
$ch = curl_init("https://slack.com/api/chat.postMessage"); | |
$data = http_build_query([ | |
"token" => "xoxp-20602861126-50564294628-131570927717-71f35607470b529281bb4cb779318048", | |
"general" => $channel, | |
"New Purchase! "+$event['$properties']['$email']+" subscribed to the "+$event['$properties']['$price']+" plan" => $message, | |
"username" => "PaymentNotifier", | |
]); | |
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; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍