Você está na página 1de 10

raduo do ingls para portugus O Voicent classe PHP contm as seguintes funes.

call_text call_audio call_status call_remove call_till_confirm Como todas essas funes so implementadas como um cliente HTTP que comunica directamente com Voicent Gateway, eles podem ser executados em qualquer mquina que tenha uma conexo com o host que executa o gateway. O cdigo-fonte php interface includa no final desta seo. Essa interface PHP desenvolvido com base em Voicent simples gateway de sada Call Interface. ________________________________________ SINOPSE call_text <phoneno> <text mensagem> <selfdelete> DESCRIO Fazer uma chamada de telefone e ouvir a mensagem de texto especificado. A mensagem de texto converter a voz por Voicent Gateway de texto-para-motor de fala.
As opes so: <phoneno> O nmero de telefone <text mensagem> A mensagem para a chamada de telefone <selfdelete> Pergunte ao gateway para apagar automaticamente a solicitao de chamada aps a chamada feita, se for definido para '1 ' O valor de retorno o pedido de chamada de ID <reqId>. EXEMPLO call_text ("123-4567", "Ol, como voc est fazendo", 1); Fazer uma chamada para o nmero de telefone '123-4567 'e dizer' Ol, como voc est fazendo ". Desde o bit selfdelete definida, o registro de solicitao de chamada no gateway ser removido automaticamente aps a chamada. $ ReqId = call_text ("123-4567", "Ol, como voc est fazendo", 0); Fazer uma chamada para o nmero de telefone '123-4567 'e dizer' Ol, como voc est fazendo ". Desde o bit selfdelete no est definido, o registro de solicitao de chamada no gateway no ser removido aps a chamada. Voc pode ento usar call_status para obter o status da chamada, ou use call_remove para remover o registro de chamada. ________________________________________ SINOPSE call_audio <phoneno> <audiofile> <selfdelete>

DESCRIO Fazer uma chamada de telefone e ouvir a mensagem udio especificado. As opes so: <phoneno> O nmero de telefone <audiofile> A mensagem de udio para o telefonema. O formato deve ser 16bit PCM, 8KHz, mono arquivo wave. O arquivo de udio deve estar no mesmo host que Voicent Gateway. <selfdelete> Pergunte ao gateway para apagar automaticamente a solicitao de chamada aps a chamada feita, se for definido para '1 ' O valor de retorno o pedido de chamada de ID <reqId>. EXEMPLO call_audio ("123-4567", "C: \ meus udios \ hello.wav", 1); Fazer uma chamada para o nmero de telefone '123-4567 'e reproduzir o arquivo hello.wav. Desde o bit selfdelete definida, o registro de solicitao de chamada no gateway ser removido automaticamente aps a chamada. $ ReqId = call_audio ("123-4567", "C: \ meus udios hello.wav \", 0); Fazer uma chamada para o nmero de telefone '123-4567 'e reproduzir o arquivo hello.wav. Desde o bit selfdelete no est definido, o registro de solicitao de chamada no gateway no ser removido aps a chamada. Voc pode ento usar call_status para obter o status da chamada, ou use call_remove para remover o registro de chamada.

________________________________________ SINOPSE <reqId> call_status DESCRIO Verifique o estado da chamada da chamada com <reqId>. Se a chamada for feita, o valor de retorno 'Call Made ", ou se a chamada falhar, o valor de retorno " Call Failed ", e para qualquer outro estado, o valor de retorno " ". Por favor note que uma string vazia retornada se a chamada ainda est em andamento. Voc vai precisar de esperar e depois consultar o estado novamente. EXEMPLO $ Status = call_status ("11234035434"); ________________________________________ SINOPSE <reqId> call_remove DESCRIO Remova o registro da chamada da chamada com <reqId>. Se a chamada no feita, no entanto, ela ser removida tambm.

EXEMPLO call_remove ("11234035434"); ________________________________________ SINOPSE call_till_confirm <vcast prog> <vcast doc> <confirmcode> <wavfile> DESCRIO Manter chamar uma lista de pessoas at que algum digita o cdigo de confirmao. A mensagem o arquivo de udio especificado. Isto ideal para us-lo em um processo de escalonamento do telefone da notificao. Para usar esse recurso, Voicent BroadcastByPhone verso Professional tem de ser instalado. Esta funo semelhante interface de linha de comando BroadcastByPhone tem. Mas desde que o comando no pode ser invocar mais de um computador remoto, esta funo perl usa o gateway para agendar um evento, que por sua vez invoca o comando na mquina gateway. As opes so:

<vcast prog> O programa BroadcastByPhone. Geralmente "C: \ Program Files \ Voicent \ BroadcastByPhone \ Vcast bin \" na mquina gateway. <vcast doc> A lista de chamadas BroadcastByPhone de usar. <confirmcode> O uso de cdigo de confirmao para a transmisso <wavfile> O arquivo de udio a ser usado para a transmisso EXEMPLO call_till_confirm ( "C: \ Program Files \ Voicent \ BroadcastByPhone \ bin \ vcast.exe", "C: \ Meus ListaCham \ escalation.voc", "911911", "C: \ Meus ListaCham escalation.wav \"); Isso ir chamar BroadcastByPhone programa na mquina gateway e comear a chamar a todos uma lista de chamadas definidas no "C: \ Meus ListaCham escalation.voc \ '. A mensagem de udio reproduzido 'C: \ Meus ListaCham escalation.wav \'. E assim que algum entra na lista o cdigo de confirmao '911911 ', a chamada ser interrompida automaticamente.

http://www.hotscripts.com/listing/voicent-gateway-php-script-for-making-phone-calls/ http://www.voicent.com/devnet/docs/simpleintf.htm http://cutesoft.net/ASP.NET+Chat/?gclid=CKLb9e-ahqkCFQoY4QodrTMSkg

The Voicent PHP class contains the following functions.


y y y y y

call_text call_audio call_status call_remove call_till_confirm

Since all these functions are implemented as a HTTP client communicating directly with Voicent Gateway, they can be run on any machine that has a connection to the host running the gateway. The php interface source code is included at the end of this section. This PHP interface is developed based on Voicent Gateway Simple Outbound Call Interface.

SYNOPSIS
call_text <phoneno> <text message> <selfdelete>

DESCRIPTION
Make a phone call and play the specified text message. The text message is convert to voice by Voicent Gateway's text-to-speech engine.

The options are:

<phoneno>

The phone number to call The message for the phone call Ask the gateway to automatically delete the call request after the call is made if it is set to '1'

<text message>

<selfdelete>

The return value is the call request id <reqId>. EXAMPLE


call_text(" 123-4567", "Hello, how are you doing", 1);

Make a call to phone number '123-4567' and say 'Hello, how are you doing'. Since the

selfdelete bit is set, the call request record in the gateway will be removed

automatically after the call.

$reqId = call_text(" 123-4567", "Hello, how are you doing", 0);

Make a call to phone number '123-4567' and say 'Hello, how are you doing'. Since the selfdelete bit is not set, the call request record in the gateway will not be removed after the call. You can then use call_status to get the call status, or use call_remove to remove the call record.

SYNOPSIS
call_audio <phoneno> <audiofile> <selfdelete>

DESCRIPTION
Make a phone call and play the specified audio message.

The options are:

<phoneno>

The phone number to call The audio message for the phone call. The format must be PCM 16bit, 8KHz, mono wave file. The audio file must be on the same host as Voicent Gateway. Ask the gateway to automatically delete the call request after the call is made if it is set to '1'

<audiofile>

<selfdelete>

The return value is the call request id <reqId>. EXAMPLE


call_audio(" 123-4567", "C: \my audios\hello.wav", 1);

Make a call to phone number '123-4567' and play the hello.wav file. Since the selfdelete bit is set, the call request record in the gateway will be removed

automatically after the call.

$reqId = call_audio(" 123-4567", "C: \my audios \hello.wav", 0);

Make a call to phone number '123-4567' and play the hello.wav file. Since the selfdelete bit is not set, the call request record in the gateway will not be removed after the call. You can then use call_status to get the call status, or use call_remove to remove the call record.

SYNOPSIS
call_status <reqId>

DESCRIPTION
Check the call status of the call with <reqId>. If the call is made, the return value is 'Call Made' , or if the call is failed, the return value is 'Call Failed' , and for any other status, the return value is "". Please note that an empty string is returned if the call is still in progress. You'll need to wait and then poll the status again.

EXAMPLE
$status = call_status(" 11234035434");

SYNOPSIS
call_remove <reqId>

DESCRIPTION
Remove the call record of the call with <reqId>. If the call is not made yet, it will be removed also.

EXAMPLE
call_remove(" 11234035434");

SYNOPSIS
call_till_confirm <vcast prog> <vcast doc> <confirmcode> <wavfile>

DESCRIPTION
Keep calling a list of people until anyone enters the confirmation code. The message is the specified audio file. This is ideal for using it in a phone notification escalation process. To use this feature, Voicent BroadcastByPhone Professional version has to be installed. This function is similar to the command line interface BroadcastByPhone has. But since the command cannot be invoke over a remote machine, this perl function uses the gateway to schedule an event, which in turn invokes the command on the gateway host. The options are:

<vcast prog>

The BroadcastByPhone program. It is usually 'C:\Program Files\Voicent\BroadcastByPhone\bin\vcast' on the gateway host. The BroadcastByPhone call list to use. The confirmation code use for the broadcast The audio file to use for the broadcast

<vcast doc>

<confirmcode>

<wavfile>

EXAMPLE
call_till_confirm( "C:\Program Files \Voicent\BroadcastByPhone \bin\vcast.exe", "C:\My calllist \escalation.voc", "911911", "C:\My calllist \escalation.wav");

This will invoke BroadcastByPhone program on the gateway host and start calling everyone one the call list defined in 'C:\My calllist \escalation.voc' . The audio message played is 'C:\My calllist \escalation.wav' . And as soon as anyone on the list enters the confirmation code '911911' , the call will stop automatically.

Source Code
<?php class Voicent { var $host = "localhost"; var $port = 8155; function _call_now($body) { $headers = "POST /ocall/ callreqHandler.jsp HTTP/1.1 \r\n" . "User-Agent: Mozilla/4.0 \r\n" . "Host: " . $this ->host . " \r\n" . "Content-Type: application/x -www-formurlencoded \r\n" . "Content-Length: " . st rlen($body) . " \r\n" . "\r\n"; if (! ($sock = fsockopen($this ->host, $this $errno, $errstr))) { echo $errstr; return false; } fwrite($sock, $headers.$body, strlen($heade rs.$body)); $reqid = ""; while ($line = fgets($sock, 4096)) { if (preg_match("/ \[ReqId=(.*) \]/", $line, $matches)) { $reqid = $matches[1]; break; } } fclose($sock); return $reqid; } function call_text($phoneno, $textmsg, $selfdelete) { $body = "info=" . urlencode("call " . $phoneno) . "&"; $body .= "phoneno=" . urlencode($phoneno) . "&"; $body .= "firstocc=10&"; $body .= "txt=" . urlencode($textmsg) . "&";

>port,

$body .= "selfdelete=" . $selfdelete; return $this ->_call_now($body); } function call_audio($phoneno, $audiofile, $selfdelete) { $body = "info=" . urlencode("call " . $phoneno) . "&"; $body .= "phoneno=" . urlencode($phoneno) . "&"; $body .= "firstocc=10&"; $body .= "audiofile=" . urlencode($audiofile) . "&"; $body .= "selfdelete=" . $selfdelete; return $this ->_call_now($body); } function call_status($reqId) { $headers = "GET /ocall/callstatusHandler.jsp?reqid=" . $reqId . " HTTP/1.1 \r\n" . "User-Agent: Mozilla/4.0 \r\n" . "Host: " . $this ->host . "\r\n" . "\r\n"; if (! ($sock = fsockopen($this ->host, $this ->port, $errno, $errstr))) { echo $errstr; return false; } fwrite($sock, $headers, strlen($headers)); $status = ""; while ($line = fgets($sock, 4096)) { if (preg_match("/ \^made\^/", $line)) { $status = "Call Make"; break; } if (preg_match("/ \^failed\^/", $line)) { $status = "Call Failed"; break; } } fclose($sock); return $status; } function call_remove($reqId) { $headers = "GET /ocall/callremoveHandler.jsp?reqid=" . $reqId . " HTTP/1.1 \r\n" . "User-Agent: Mozilla/4.0 \r\n" . "Host: " . $this ->host . "\r\n" . "\r\n"; if (! ($sock = fsockopen($this ->host, $this ->port, $errno, $errstr))) { echo $errstr; return false; }

fwrite($sock, $headers, strlen($headers)); $line = fgets($sock, 4096); fclose($sock); } function call_till_confirm($vcast, $voc, $confirmcode, $wavefile) { $body = "info=" . urlencode("call till confirm") . "&"; $body .= "phoneno=0000000" . "&"; $body .= "firstocc=10&"; $body .= "startexec=" . urlencode($vcast) . "&"; $body .= "selfdelete=" . $selfdelete . "&"; $cmdline = " \"" . $voc . " \" -startnow -confirmcode " . $confirmcode; $cmdline .= " -wavfile \"" . $wave file . "\""; $body .= "cmdline=" . urlencode($cmdline); return $this ->_call_now($body); } } # $voicent = new Voicent; # $id = $voicent ->call_text("1234567", "hello, how are you", "0"); # print $id; # $id = $voicent ->call_audio("123456 7", "C:\Temp\welcome.wav", 0); # print $id; # print $voicent ->call_status("1103704332609"); # $voicent ->call_remove("1103704332609"); # print $voicent ->call_status("1103704332609"); ?>