Page 1 of 1

Posting and recieving data with php/vxml

Posted: Mon Oct 09, 2006 5:21 pm
by brent.russell
A few questions here:

In php I post data to another script with
would I do it this way in VXML where vxmlvar1 and vxmlvar2 are actual variables contained within vxml:

Code: Select all

<submit next="script.php" value1="vxml_var1" value2="vxml_var2" method="post"/>
What if my php script has a variable that needs send back such as customerID=MM134G57923B? How do I get that information into a variable that vxml can use?

Also, can I specify an external php script in my submit tag or do the scripts have to reside on the plum servers?

IVR ex that collects information & posts info to PHP scr

Posted: Mon Oct 09, 2006 7:45 pm
by support
Hello,

Generally speaking all of the VoiceXML you write should reside on your IVR application server. You should follow the development process much like you follow standard HTML development. The Plum IVR Platform acts more or less like a remote web browser from the perspective of your IVR application server.

Prepopulating information that will be sent to your IVR application server can be done by assigning values in a script and then placing those variables in the namelist attribute of your <submit> tag. Here is an IVR example that collects information, posts that information to a PHP script which then reuses the posted information to provide an option to the user:

start.vxml:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <field name="id" type="digits">
      <prompt>Please enter your I D</prompt>
    </field>
    <field name="pin" type="digits">
      <prompt>Please enter your pin</prompt>
    </field>
    <filled>
      <submit next="auth.php" namelist="id pin" method="post"/>
    </filled>
  </form>
</vxml>

auth.php:

Code: Select all

<?php 
echo("<?xml version=\"1.0\"?>\n");
include_once("somedatabasecode.php");
?>
<vxml version="2.0">
  <form>
<?php if (authenticate($_POST['id'], $_POST['pin'])) { ?>
    <field name="check_account" type="boolean">
      <prompt>Press 1 if you would like to check your balance or press 2 to disconnect</prompt>
      <filled>
        <if cond="check_account">
          <!-- assign the ecmascript variables with the known good id -->
          <var name="id" expr="'<?php echo($_POST['id']);?>'"/>
          <submit next="check_account.php" namelist="id" method="post"/>
        </if>
      </filled>
    </field>
<?php } else { ?>
    <block>
      <prompt>Unauthorized access. Goodbye.</prompt>
      <disconnect/>
    </block>
<?php } ?>

check_balance.php:

Code: Select all

<?php 
echo("<?xml version=\"1.0\"?>\n");
include_once("somedatabasecode.php");
?>
<vxml version="2.0">
  <form>
    <block>
      <prompt>Your account balance is <?php echo(check_balance($_POST['id']))?>.  Goodbye.</prompt>
      <disconnect/>
    </block>
  </form>
</vxml>
Regards,
Plum Support