PHP code example of asanak / php-web-call-client

1. Go to this page and download the library: Download asanak/php-web-call-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

asanak / php-web-call-client example snippets


use Asanak\WebCallClient;
use Asanak\WebCallConfig;

$config = new WebCallConfig([
    'base_url' => 'https://callapi.asanak.com'
]);
$client = new WebCallClient('your-username', 'your-password', $config);

try {
    $response = $client->uploadNewVoice('/path/file/voice.mp3');
    var_dump($response);
} catch(\Throwable $th) {
    echo $th->getMessage();
}

try{
    $response = $client->callByVoice('VOICE_FILE_ID', '09120000000');
    var_dump($response);
} catch(\Throwable $th) {
    echo $th->getMessage();
}

try{
    $response = $client->callByOtp(1234, '09120000000');
    var_dump($response);
} catch(\Throwable $th) {
    echo $th->getMessage();
}

try{
    $response = $client->callStatus(['CALL_ID_1', 'CALL_ID_1']);
    var_dump($response);
} catch(\Throwable $th) {
    echo $th->getMessage();
}

try{
    $response = $client->getCredit();
    var_dump($response);
} catch(\Throwable $th) {
    echo $th->getMessage();
}


use Asanak\WebCallClient;
use Asanak\WebCallConfig;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('web-call-client');
$logger->pushHandler(new StreamHandler(__DIR__.'/debug.log'));

$config = new WebCallConfig([
    'base_url' => 'https://callapi.asanak.com'
]);
$client = new WebCallClient('username', 'password', $config, $logger);