<?php

// Include the PHP Plivo Rest library
require "../plivohelper.php";
$REST_API_URL = 'http://127.0.0.1:8088';
// Plivo REST API version
$ApiVersion = 'v0.1';
// Set our AccountSid and AuthToken
$AccountSid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$AuthToken = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY';
// Instantiate a new Plivo Rest Client
$client = new PlivoRestClient($REST_API_URL, $AccountSid, $AuthToken, $ApiVersion);
// ========================================================================
# Define Channel Variable - http://wiki.freeswitch.org/wiki/Channel_Variables
$extra_dial_string = "bridge_early_media=true,hangup_after_bridge=true";
# Initiate a new outbound call to user/1000 using a HTTP POST
$call_params = array('From' => '919191919191', 'To' => '1000', 'Gateways' => "user/", 'GatewayCodecs' => "'PCMA,PCMU'", 'GatewayTimeouts' => "60", 'GatewayRetries' => "1", 'ExtraDialString' => $extra_dial_string, 'AnswerUrl' => "http://127.0.0.1:5000/answered/", 'HangupUrl' => "http://127.0.0.1:5000/hangup/", 'RingUrl' => "http://127.0.0.1:5000/ringing/");
try {
    // Initiate call
    $response = $client->call($call_params);
    print_r($response);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    exit(0);
}
// check response for success or error
if ($response->IsError) {
    echo "Error starting phone call: {$response->ErrorMessage}\n";
} else {
    echo "Started call: {$response->Response->RequestUUID}\n";
}
<?php

// Include the PHP Plivo Rest library
require "../plivohelper.php";
$REST_API_URL = 'http://127.0.0.1:8088';
// Plivo REST API version
$ApiVersion = 'v0.1';
// Set our AccountSid and AuthToken
$AccountSid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$AuthToken = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY';
// Instantiate a new plivo Rest Client
$client = new PlivoRestClient($REST_API_URL, $AccountSid, $AuthToken, $ApiVersion);
// ========================================================================
# Hangup a call using a HTTP POST
$hangup_call_params = array('CallUUID' => 'edaa59e1-79e0-41de-b016-f7a7570f6e9c');
try {
    // Hangup call
    $response = $client->hangup_call($hangup_call_params);
    print_r($response);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    exit(0);
}
<?php

// Include the PHP Plivo Rest library
require "../plivohelper.php";
$REST_API_URL = 'http://127.0.0.1:8088';
// Plivo REST API version
$ApiVersion = 'v0.1';
// Set our AccountSid and AuthToken
$AccountSid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$AuthToken = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY';
// Instantiate a new plivo Rest Client
$client = new PlivoRestClient($REST_API_URL, $AccountSid, $AuthToken, $ApiVersion);
// ========================================================================
# Hangup a call using a HTTP POST
$transfer_call_params = array('Url' => "http://127.0.0.1:5000/transfered/", 'CallUUID' => 'edaa59e1-79e0-41de-b016-f7a7570f6e9c');
try {
    // Transfer call
    $response = $client->transfer_call($transfer_call_params);
    print_r($response);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    exit(0);
}
Ejemplo n.º 4
0
if (isset($_POST['callbacknum'])) {
    $cn = $_POST['callbacknum'];
    //vérification du numéro de téléphone, et ajout du préfix international si nécéssaire.
    if (!isPhone($cn)) {
        $ERR = "Le numéro entré est invalide";
    }
    if (!hasInternationalExt($cn)) {
        $cn = substr($cn, 1, strlen($cn) - 1);
        $cn = $cn + "0033";
    }
    $MSG = "Nous allons vous appeler dans quelques instants..";
    if (!isset($ERR)) {
        //## Code plivo pour le controle de Freeswitch
        require "lib/plivo/plivohelper.php";
        //instanciation du client plivo
        $client = new PlivoRestClient($REST_API_URL, $AccountSid, $AuthToken, $ApiVersion);
        //$bridge_id = genBridgeUUID(1);
        //$bridge_id = '1234';
        //cree un nouvel uuid dans freeswitch
        $params = array();
        $response = $client->create_uuid($params);
        $bridge_id = $response->Response->Message;
        $params = array('command' => "luarun bridge.lua {$bridge_id} sofia/gateway/{$sipconf}/{$cn} sofia/gateway/{$sipconf2}/{$callto} sofia/gateway/{$sipconf}/{$cn} sofia/gateway/{$sipconf2}/{$callto} lqdn_itre_acta.wav", 'bg' => 'true');
        try {
            // Initiate bridge
            $response = $client->command($params);
        } catch (Exception $e) {
            echo 'Caught exception: ', $e->getMessage(), "\n";
            exit(0);
        }
        //##
Ejemplo n.º 5
0
<?php

//echo "##DEBUG###";
if (!isset($_GET['uuid'])) {
    die("Error: no uuid.");
}
$uuid = $_GET['uuid'];
require "../lib/plivo/plivohelper.php";
$REST_API_URL = 'http://127.0.0.1:8088';
$ApiVersion = 'v0.1';
$AccountSid = 'pheingahg4keeHi8eghaeroish5Ahh';
$AuthToken = 'ye1Eeseozio9aeHengouSaifood8la';
//instanciation du client plivo
$client = new PlivoRestClient($REST_API_URL, $AccountSid, $AuthToken, $ApiVersion);
$params = array('UUID' => $uuid, 'varName' => 'hangup_cause');
try {
    $res = $client->get_var($params);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    exit(0);
}
if (!$res) {
    die('Response object = NULL');
}
if (strpos($res->Response->Message, "-ERR") === 0) {
    echo "FINISHED";
} else {
    echo "OK";
}
Ejemplo n.º 6
0
 /** This function uses plivo API to make the callback
  */
 private function _callback($from, $to, $wavfile, $lang)
 {
     //## Code plivo pour le controle de Freeswitch
     require_once "plivo/plivohelper.php";
     //instanciation du client plivo
     $client = new PlivoRestClient(REST_API_URL, AccountSid, AuthToken, ApiVersion);
     //cree un nouvel uuid dans freeswitch
     $params = array();
     $response = $client->create_uuid($params);
     $bridge_id = $response->Response->Message;
     // Search for the wav file for this campaign :
     if (!$wavfile || !file_exists("/usr/local/freeswitch/sounds/" . $wavfile)) {
         $wavfile = "lqdn_ann.wav";
     }
     // Search for a local language wav file
     if (file_exists("/usr/local/freeswitch/sounds/" . str_replace(".wav", "-" . $lang . ".wav", $wavfile))) {
         $wavfile = str_replace(".wav", "-" . $lang . ".wav", $wavfile);
     }
     //    $this->log($bridge_id."/".$from."/".$to."/".$wavfile);
     // WARNING : I don't use wintermew bridge.lua anymore, modified for SIP trunk on nnx ...
     $params = array('command' => "luarun bridge.lua {$bridge_id} {$from} {$to} {$wavfile}", 'bg' => 'true');
     try {
         // Initiate bridge
         $response = $client->command($params);
         return $bridge_id;
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         return false;
     }
     //##
 }
<?php

// Include the PHP Plivo Rest library
require "../plivohelper.php";
$REST_API_URL = 'http://127.0.0.1:8088';
// Plivo REST API version
$ApiVersion = "v0.1";
// Set our AccountSid and AuthToken
$AccountSid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
// Instantiate a new Plivo Rest Client
$client = new PlivoRestClient($REST_API_URL, $AccountSid, $AuthToken, $ApiVersion);
// ========================================================================
# Define Channel Variable - http://wiki.freeswitch.org/wiki/Channel_Variables
$extra_dial_string = "bridge_early_media=true,hangup_after_bridge=true";
# Initiate a new outbound call to user/1000 using a HTTP POST
$call_params = array('Delimiter' => '>', 'From' => '919191919191', 'To' => '1000>1000', 'Gateways' => "user/>user/", 'GatewayCodecs' => "'PCMA,PCMU'>'PCMA,PCMU'", 'GatewayTimeouts' => "60>30", 'GatewayRetries' => "2>1", 'ExtraDialString' => $extra_dial_string, 'AnswerUrl' => "http://127.0.0.1:5000/answered/", 'HangupUrl' => "http://127.0.0.1:5000/hangup/", 'RingUrl' => "http://127.0.0.1:5000/ringing/");
try {
    // Initiate various calls
    $response = $client->bulk_call($call_params);
    print_r($response);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    exit(0);
}
// check response for success or error
if ($response->IsError) {
    echo "Error starting phone calls: {$response->ErrorMessage}\n";
} else {
    echo "Started calls: {$response->Response->RequestUUID}\n";
}