Last active
February 24, 2019 19:23
-
-
Save edguy3/4eb933c6c2901aa939425732d2fb86ee to your computer and use it in GitHub Desktop.
Respond to Signal wire incoming SMS webhook. PHP example.
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 | |
// use composer to ‘require signalwire/signalwire’ | |
require_once 'vendor/autoload.php'; | |
// record input PLEASE CLEAN INPUT BEFORE HANDLING | |
syslog(LOG_WARNING, print_r($_POST, true)); | |
syslog(LOG_WARNING, "MessageSid: ".$_POST["MessageSid"]); | |
syslog(LOG_WARNING, "SmsSid: ".$_POST["SmsSid"]); | |
syslog(LOG_WARNING, "AccountSid: ".$_POST["AccountSid"]); | |
syslog(LOG_WARNING, "From: ".$_POST["From"]); | |
syslog(LOG_WARNING, "To: ".$_POST["To"]); | |
syslog(LOG_WARNING, "Body: ".$_POST["Body"]); | |
syslog(LOG_WARNING, "NumMedia: ".$_POST["NumMedia"]); | |
// generate resposne | |
$response = new SignalWire\LaML(); | |
// Do local processing and if text to be sent in response, use “message” api | |
//$response->message("OKIE DOKIE"); | |
echo $response; | |
// returns | |
// <?xml version="1.0" encoding="UTF-8"?> | |
// <Response></Response> | |
// or with the message: | |
// <Response><Message>OKIE DOKIE</Message></Response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment