PHP code example of sazanof / novofon-api-v2

1. Go to this page and download the library: Download sazanof/novofon-api-v2 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/ */

    

sazanof / novofon-api-v2 example snippets



use Sazanof\NovofonApiV2\NovofonDataApi;
$app = NovofonDataApi::initialize('appid', 'token');

$options = [
    'verify'=>false
];

$app = NovofonDataApi::initialize(
    'appid', 
    'token',
    $options
);

$app->filter->rule('phone_number', '=', '123456');

/** FILTER FOR SIP LINES */
$app->filter->group(function (\Sazanof\NovofonApiV2\Builder\FilterGroup $group) {
    $group->or(function (\Sazanof\NovofonApiV2\Builder\FilterGroup $group) {
        $group->add('phone_number', '=', '123456');
        $group->add('phone_number', '!=', '666');
        $group->or(function (\Sazanof\NovofonApiV2\Builder\FilterGroup $group) {
            $group->add('phone_number', '=', '777');
            $group->add('phone_number', '=', '9999');
        });
    });
}, 'and');

$app->orderBy('employee_id', \Sazanof\NovofonApiV2\Builder\Sort::DESC);

$app
    ->setLimit(10)
    ->setOffset(5)
    ->removeLimit()
    ->removeOffset();

try {
    foreach ($app->getSipLines()->lines->items() as $item) {
        dump($item->phoneNumber);
    }
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
    //
} catch (\Sazanof\NovofonApiV2\Exceptions\BaseError $e) {
    // 
}
// OR
foreach ($app->setLimit(10)->setOffset(33)->getEmployees()->employees->items() as $item) {
    dump($item->extension);
}
// Virtual Lines
foreach ($app->getVirtualNumbers()->numbers->items() as $virtualNumber) {
    dump($virtualNumber->scenarios); // ->  \Sazanof\NovofonApiV2\Collections\ScenariosCollection::class
    dump($virtualNumber->status);
}