masterfermin02/vicidial-api-wrapper

美观且简单的Vicidial API集成实现

v3.0.1 2023-11-18 14:24 UTC

This package is auto-updated.

Last update: 2024-09-27 22:29:29 UTC


README

美观且简单的Vicidial API集成实现

免责声明:VICIdial是Vicidial集团注册商标,与本机构无关。

VICIDIAL是一款软件套件,旨在与Asterisk开源PBX电话系统交互,作为一个完整的 inbound/outbound 联系中心套件,同时提供 inbound 邮件支持。

http://www.vicidial.org/vicidial.php

Vicidial具有代理API和非代理API,这些类旨在使其在PHP中使用更加便捷

安装

需要PHP 8.1

composer require masterfermin02/vicidial-api-wrapper

对于PHP 7.4+必须安装此版本

composer require masterfermin02/vicidial-api-wrapper:1.0.3

如何使用

示例1:更新代理屏幕上的字段

<?php

$fields['first_name'] = "John";
$fields['last_name'] = "Doe";
$fields['address1'] = "123 Fake St";

try {
     $agentApi = VicidialApi::create(
        getenv('YOUR_VICIDIAL_IP'),
        getenv('YOUR_VICIDIAL_USER'),
        getenv('YOUR_VICIDIAL_PASSWORD')
     )->agent();
     echo $agentApi->updateFields("gabriel", $fields);
} catch (Exception $e) {
     echo 'Exception: ',  $e->getMessage(), "\n";
}

示例2:挂断电话,分配它并暂停代理

<?php

try {
     $agentApi = VicidialApi::create(
        getenv('YOUR_VICIDIAL_IP'),
        getenv('YOUR_VICIDIAL_USER'),
        getenv('YOUR_VICIDIAL_PASSWORD')
     )->agent();
     $agentApi->pause("gabriel", "PAUSE");
     $agentApi->hangup("gabriel");
     $agentApi->dispo("gabriel", ['value' => 'SALE']);
     $agentApi->pauseCode("gabriel", "BREAK");
} catch (Exception $e) {
     echo 'Exception: ',  $e->getMessage(), "\n";
}

示例3:更新代理屏幕上的字段

    <?php
    
    $fields['first_name'] = "John";
    $fields['last_name'] = "Doe";
    $fields['address1'] = "123 Fake St";
    
    try {
         $agentApi = VicidialApi::create(
             getenv('YOUR_VICIDIAL_IP'),
             getenv('YOUR_VICIDIAL_USER'),
             getenv('YOUR_VICIDIAL_PASSWORD')
         )->agent();
         echo $agentApi->updateFields("gabriel", $fields);
    } catch (Exception $e) {
         echo 'Exception: ',  $e->getMessage(), "\n";
    }

Vicidial管理员或无代理API

    <?php
    
    require_once 'vendor/autoload.php';
    
    try {
        $agentApi = VicidialApi::create(
            getenv('YOUR_VICIDIAL_IP'),
            getenv('YOUR_VICIDIAL_USER'),
            getenv('YOUR_VICIDIAL_PASSWORD')
        )->admin();
        echo $agentApi->mohList([
            'format' => 'selectframe',
            'comments' => 'fieldname',
            'stage' => 'date'
        ]);
    } catch (Exception $e) {
        echo 'Exception: ',  $e->getMessage(), "\n";
    }

URL编码

    <?php
    
    require_once 'vendor/autoload.php';

    $fields['first_name'] = "John";
    $fields['last_name']  = "Doe";
    $fields['address1']   = "123 Fake St";
    $fields['phone_number']   = "18002474747";
    
    try {
        $agentApi = VicidialApi::create(
            getenv('YOUR_VICIDIAL_IP'),
            getenv('YOUR_VICIDIAL_USER'),
            getenv('YOUR_VICIDIAL_PASSWORD'),
            "test",
            false
        )->admin();
        echo $agentApi
        ->withUrlEncode(true)
        ->addLead($fields);
    } catch (Exception $e) {
        echo 'Exception: ', $e->getMessage(), "\n";
    }

登录远程代理

    <?php
    
    require_once 'vendor/autoload.php';
    
    try {
        $remoteAgent = VicidialApi::createWithBasicAuth(
            getenv('YOUR_VICIDIAL_IP'),
            getenv('YOUR_VICIDIAL_API_USER'),
            getenv('YOUR_VICIDIAL_API_PASSWORD'),
            getenv('YOUR_VICIDIAL_REMOTE_AGENT'),
            getenv('YOUR_VICIDIAL_REMOTE_PASSWORD'),
        )->remoteAgent();
        $remoteAgent->active(
            getenv('agentId'),
            getenv('confExten'),
        );
        $remoteAgent->hangUp(
            "gabriel",
            [
            'status' => 'SALE',
            ]
]
        );
        $remoteAgent->inActive(
            getenv('agentId'),
            getenv('confExten'),
        );
    } catch (Exception $e) {
        echo 'Exception: ',  $e->getMessage(), "\n";
    }

文档