PHP code example of cloudloyalty / amocrm-client

1. Go to this page and download the library: Download cloudloyalty/amocrm-client 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/ */

    

cloudloyalty / amocrm-client example snippets


$client = new Client(
    $config['amocrm_subdomain'],
    $config['amocrm_login'],
    $config['amocrm_api_key']
);


$data = $client->createUnsortedForm()
    ->setSourceName('ourdomain.com')
    ->setSourceUid(date('YmdHis'))
    ->setFormId($formId)
    ->setFormPage('New request')
    ->setIp($clientIp)
    ->setServiceCode('wtf')
    ->setFormName($formName)
    ->setReferer($clientReferer)
    ->addIncomingContact(
        $client->createContact()
            ->setName($clientName)
            ->addCustomField(
                $client->createCustomField($config['amocrm_phone_id'])
                    ->addValue($clientPhone, $config['amocrm_phone_enum'])
            )
    )
    ->addIncomingLead(
        $client->createLead()
            ->setName('New request from ' . $clientName)
    );

// send data to server
$client->persist($data);