PHP code example of ictinnovations / php-crm-connectors

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

    

ictinnovations / php-crm-connectors example snippets


use ICTInnovations\CrmConnectors\ConnectorFactory;

$crm = ConnectorFactory::make('zoho', [
    'client_id'     => getenv('ZOHO_CLIENT_ID'),
    'client_secret' => getenv('ZOHO_CLIENT_SECRET'),
    'refresh_token' => getenv('ZOHO_REFRESH_TOKEN'),
    'module'        => 'Leads',
    'disposition_map' => ['Interested' => 'Qualified', 'Sale' => 'Won'],
]);

$result = $crm->run([
    'phone'      => '+1 (202) 555-0147',
    'first_name' => 'Jane',
    'last_name'  => 'Doe',
    'email'      => '[email protected]',
    'campaign_name'   => 'Summer Outreach',
    'disposition'     => 'Interested',   // mapped -> 'Qualified' via disposition_map
    'disposition_crm' => 'Qualified',
    'duration'        => 73,
    'history_comments'=> 'Asked for a callback next week.',
    'time_connect'    => time(),
]);
// => ['remote_id' => '3652...', 'remote_module' => 'Leads']  (upserted + note + call activity)

$crm->authenticate();
$id = $crm->findContactByPhone('12025550147') ?? $crm->findContactByEmail('[email protected]');
$id = $id ?? $crm->createContact(['first_name'=>'Jane','last_name'=>'Doe','phone'=>'...','email'=>'...']);
$crm->updateContact($id, [/* CRM-native fields */]);
$crm->createNote($id, ['subject'=>'Call', 'content'=>'...']);
$crm->createActivity($id, ['subject'=>'Call', 'duration'=>73, 'time_connect'=>time()]);

use ICTInnovations\CrmConnectors\Support\{FileTokenStore, CallableLogger};

$crm = ConnectorFactory::make('pipedrive', $config,
    new FileTokenStore('/var/cache/crm-tokens.json'),
    new CallableLogger(fn($lvl,$msg) => error_log("[$lvl] $msg")));
bash
composer