I am trying to pass a simple phone number to a vxml block. How can I pass a dynamic variable into this?
$my_phone_number_here = '12197719191';
$string = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<menu dtmf="true">
<prompt>
<audio src="http://my.site.com/app/service-interaction-center.mp3"/>
</prompt>
<choice dtmf="1" next="#sales"/>
</menu>
<form id="sales">
<block>
<audio src="http://my.site.com/app/service-interaction-center-thank-you.mp3"/>
</block>
<transfer name="MyCall" dest="tel:+{$my_phone_number_here}" bridge="true" connecttimeout="20s"/>
</form>
</vxml>
XML;
I have tried to convert that into using:
$string = '';
$string .= $to_call;
$string .= '';
etc...
But that didn't seem to work either. I would just like to get a single php variable to show up at {my_phone_number_here}, what am I missing that won't allow this to work correctly?
EDIT:
The shown code now renders with the phone number in place but my call never actually gets connected. When the call is placed, you get to listed to the audio, and press a prompt, and then the thank you announcement plays - but then it rings for a split second and the call drops. Still has to be something with xml. Any thoughts?
You could load it into a Parser (DOMDocument in particular), and change it from there using
->setAttribute()
:Simple Example:
Or just simply substitute and put a variable inside and let it be interpolated: