I'm working on a plugin that deals with Twilio. Twilio makes a post request to the plugin and I have to respond with Twiml which is really just xml. If I try sending it through like this
$wp_response = new WP_REST_Response( $response );
$wp_response->header( 'Content-Type', 'text/xml' );
return $wp_response;
it gets converted into JSON and ends up empty ({}). I could do this
header( 'Content-Type: text/xml' );
echo $response;
and it works. But then I am echoing without escaping technically. And I am not returning anything. $response in this case is properly formatted Twiml/XML built from the Twilio sdk.
How am I supposed to respond to the Api call? Is it ok if I just echo out the response? Or is there something else I should be doing?