PHP Quickstart: Playing MP3 for Caller

Play an mp3 for the Caller

That's nice, now let's play the sound of a nice monkey howl for the caller after we greet them by name.


    // make an associative array of callers we know, indexed by phone number
    $people = array(
        "+14158675309"=>"Curious George",

    // if the caller is known, then greet them by name
    // otherwise, consider them just another monkey
    if(!$name = $people[$_REQUEST['From']])
        $name = "Monkey";

    // now greet the caller
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    <Say>Hello <?php echo $name ?>.</Say>

This example uses the <Play> verb to fetch and play an MP3 file to the caller.

A recorded monkey howl is great, but our callers want more. Let's give them the option to talk to a real primate.

Next: Connect Call to Second Person »