Unity Prompt Upload

For that horrible time before you were on 11.5 and had the HTML5 prompt uploader and after your Java had already upgraded and when AudioText Manager didn’t work for whatever reason. Here is the API type way to upload a prompt to unity. You will need to find out the call handler/user object ID by going to https:///vmrest/handlers/callhandlers or go to https:///vmrest/users?query=(DtmfAccessId = 1001) and look for the CallHandlerURI and plop that in here updating the rest as needed. Prompt needs to be in the correct format – g711.org provdes easy converting


#!/usr/bin/php -q
<?php

  $host     = "172.20.0.12";
  $username = "admin";
  $password = "<password>";


function promptUpload($callhander_id,$greeting,$prompt_file) {

    global $host;
    global $username;
    global $password;
    $prompt = fopen($prompt_file,"r");

    $cupiurl="https://".$host.":8443/vmrest/handlers/callhandlers/"
            .$callhander_id."/greetings/".$greeting.
            "/greetingstreamfiles/1033/audio";

    $ch=curl_init();
    curl_setopt( $ch, CURLOPT_URL, $cupiurl );
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: audio/wav'));
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

    curl_setopt($ch, CURLOPT_PUT, 1);
    curl_setopt($ch, CURLOPT_INFILE, $prompt);
    curl_setopt($ch, CURLOPT_INFILESIZE, filesize($prompt_file));

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($ch);
    curl_close($ch);


    $cupi = json_decode(json_encode((array)simplexml_load_string($result)),1);

  fclose($prompt);

    return var_dump($cupi);
}


//Prompt Names = Standard, Alternate, Error, Internal, Holiday, Off Hours, Busy
promptUpload("ca22db19-1428-4a11-9435-84534844a967","Off Hours","./prompt.wav");

echo "\n\n";

?>