Login   Register  
PHP Classes
elePHPant
Icontem

File: news.vxml.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ben Yacoub Hatem  >  VXML  >  news.vxml.php  >  Download  
File: news.vxml.php
Role: Example script
Content type: text/plain
Description: A sample usage of php/mysql in vxml application
Class: VXML
generate easily VXML document
Author: By
Last change:
Date: 12 years ago
Size: 2,535 bytes
 

Contents

Class file image Download
<?php

/*
* @description PHP script that read summary news from your website database
* and return it as a vxml application

* A sample usage of php/mysql in vxml application

* sample Mysql Table

create table news (
  id int(4) NOT NULL auto_increment,
  summary tinytext NOT NULL,
  PRIMARY KEY  (news_id)
) TYPE=MyISAM;

* @Author    Ben Yacoub Hatem info@dynamix-tn.com
* @version    1.0.0
* @date        04-12-2002
)
*/

    // Config
    
$host ""// MySQL host
    
$user ""// User login
    
$pass ""// User passwd
    
$db   ""// News database
    
$query "SELECT summary FROM news order by id DESC LIMIT 0,3"// MySQL Query
    // End config


    
include ("vxml.class.php");
    
    
$vxml_object=new voicexml;
    
$vxml_object->_encoding "windows-1256";
    
    
$vxml_object->start_vxml_header($lang="en");
    
        
$vxml_object->vxml_start_property("caching","safe");
        
$vxml_object->vxml_start_property("maintainer","info@dynamix-tn.com" );

        
// Creation du menu
        
$vxml_object->vxml_start_menu("choix");
        
            
$vxml_object->vxml_start_prompt();
            
                
$vxml_object->vxml_audio("Welcome to dynamix news, please say : one, two or three to read news.");
                
                
$vxml_object->vxml_choice("#1","one" );
                
$vxml_object->vxml_choice("#2","two" );
                
$vxml_object->vxml_choice("#3","three" );
                
// I'm not sure if <default> is vxml 2.0 standard so i'm using addtext()
                
$vxml_object->addtext("<default><reprompt/></default>");

            
$vxml_object->end_vxml_prompt();
        
        
$vxml_object->end_vxml_menu();
        
// Read news from MySQL Database

    /* Connecting, selecting database */
    
$link = @mysql_connect($host$user$pass)
        or die(
"Could not connect");

    @
mysql_select_db($db) or die("Could not select database");

    
/* Performing SQL query */
    
$result = @mysql_query($query) or die("Query failed");
    
$i 1;
    while (
$line = @mysql_fetch_array($resultMYSQL_ASSOC)) {
        foreach (
$line as $summary) {
        
$text strip_tags($summary);
        
            
// VXML code
            
$vxml_object->vxml_start_form($i);
                
$vxml_object->vxml_start_block();
                
                    
$vxml_object->vxml_audio($summary);
                    
$vxml_object->vxml_start_goto("_home");
                    
                
$vxml_object->end_vxml_block();
            
$vxml_object->end_vxml_form();
            
// End VXML code

            
$i++;
        }
    }
    
/* Free resultset */
    
mysql_free_result($result);

    
/* Closing connection */
    
mysql_close($link);

// End MySQL         

    
$vxml_object->end_vxml();
    
    
$vxml_object->generate();

?>