PHP code example of wearesho-team / evrotel

1. Go to this page and download the library: Download wearesho-team/evrotel 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/ */

    

wearesho-team / evrotel example snippets




use Wearesho\Evrotel;

/** @var Evrotel\ConfigInterface $config */

$receiver = new Evrotel\Receiver($config);

try {
    $request = $receiver->getRequest();
    
    if($request instanceof Evrotel\Receiver\Request\Start) {
        /**
          * You have to return ID in response body
          * to receive it in call end request  
          */
        return 1;
    } elseif ($request instanceof Evrotel\Receiver\Request\End) {
        // Do something with call end request
        
        return;
    }
}
catch (Evrotel\Exceptions\AccessDenied $denied) {
    // Return 403
}
catch(Evrotel\Exceptions\BadRequest $badRequest) {
    // Return 400
}



use Wearesho\Evrotel;

/** @var Evrotel\ConfigInterface $config */
/** @var GuzzleHttp\Client $client */

$repository = new Evrotel\AutoDial\MediaRepository($config, $client);
$link = 'https://server.com/file.wav'; // Public link to auto dial file, Mono, 16 Bits,8000Hz, wav

try {
    $fileName = $repository->push($link);
}
catch(Evrotel\Exceptions\AutoDial\PushMedia $media) {
    // handle errors
}



use Wearesho\Evrotel;

/** @var Evrotel\ConfigInterface $config */
/** @var GuzzleHttp\Client $client */

$worker = new Evrotel\AutoDial\Worker($config, $client);

/** @var string $fileName returned from MediaRepository */
/** @var string $phone in format 380XXXXXXXXX */

$request = new Evrotel\AutoDial\Request($fileName, $phone);

$worker->push($request);



use Wearesho\Evrotel;

$baseConfig = new Evrotel\Config($token = 'token', $billCode = 6667);
$config = new Evrotel\Statistics\Config;
/** @var GuzzleHttp\Client $guzzle */

$client = new Evrotel\Statistics\Client($baseConfig, $config, $guzzle);
$client->getCalls($isAuto = true);



use Wearesho\Evrotel;

/** @var Evrotel\Config $config */
/** @var GuzzleHttp\Client $guzzle */

$client = new Evrotel\Initializer\Client($config, $guzzle);

$operators = [
   '101',
   '102',  
];
try {
    $client->start('380970000000', $operators);    
}
catch(\RuntimeException $exception) {
    // Evrotel returned `bad` response
}