From the TwiML Bin I found this reference to {{body}}
and {{from}}
but they don't work in TwiML as far as callbacks go. I'm having trouble getting the message details in the callback and I haven't been able to find suitable reference documenting it.
This is what I have (and this is confirmed working):
add_action( 'rest_api_init', 'register_receive_message_route');
/**
* Register the receive message route.
*
*/
function register_receive_message_route() {
register_rest_route( 'srsms/v1', '/receive_sms', array(
'methods' => 'POST',
'callback' => 'trigger_receive_sms',
) );
}
/**
* The Callback.
*
*/
function trigger_receive_sms() {
$y = "this works"; //$_POST['Body'], 0, 1592); << this doesn't
echo ('<?xml version="1.0" encoding="UTF-8"?>');
echo ('<Response>');
echo (" <Message to='+NUMBER'>xxx $y xxx</Message>");
echo ('</Response>');
die();
}
What I'm missing is passing the body to the forwarded message. I have tried quite a few snippets at the end of the call back, but I'm really just guessing here.