PHP code example of cuongcds / octivo-php

1. Go to this page and download the library: Download cuongcds/octivo-php 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/ */

    

cuongcds / octivo-php example snippets


use Octivo\Crm\OctivoClient;
use Octivo\Crm\LeadRequest;
use Octivo\Crm\Exception\ValidationException;
use Octivo\Crm\Exception\ApiException;

// baseUrl defaults to https://octivo.cloud; pass one to target a different environment.
$client = new OctivoClient('your-channel-source-id');

$request = LeadRequest::create()
    ->withName('Nguyen Van A')
    ->withEmail('[email protected]')
    ->withPhone('0912345678')
    ->withMeta('usecase', 'chatbot_sales')
    ->withMeta('utm_source', 'facebook-ads')
    ->withMeta('utm_campaign', 'spring-promo');

try {
    $result = $client->createLead($request);
    // $result->id, $result->success
} catch (ValidationException $e) {
    // neither email nor phone was provided
} catch (ApiException $e) {
    // API rejected the request: $e->getStatusCode(), $e->getMessage(), $e->getResponseBody()
}
bash
composer 
bash
composer install
OCTIVO_SOURCE_ID=your-channel-source-id php examples/create-lead.php