PHP code example of otago / crm

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

    

otago / crm example snippets


use OP\CRM;

// Step 1: Define the operations
$operations = [
    [
        'method' => 'DELETE',
        'url' => "/Lead(LeadID=3)",
    ],
    [
        'method' => 'POST',
        'url' => "/Lead",
        'data' => [
            "FirstName" => "John",
            "LastName" => "Doe",
            "Email" => "john.doe@example.com",
            "Phone" => "123-456-7890",
        ],
    ],
];

// Step 2: Send the batch request
$response = CRM::sendBatchRequest($operations);

// Step 3: Optionally Handle the Fibre. If you want to check the fibre result, this will cause it to block
echo $response;

	try {
	  CRM::request(
	    'https://your_organisation.crm5.dynamics.com/api/data/v8.2/leads',
	    'POST',
	    array(
	      "subject" => "Website Enquiry",
	      "emailaddress1" => $do->YourEmail,
	      "firstname" => $do->YourName,
	      "jobtitle" => $do->Message
	    )
	  );
	} catch ( Exception $e) {
	  throw new SS_HTTPResponse_Exception('failure to connect to crm: '.$e->getMessage());
	}

	try {
	  CRM::request(
	    'https://your_organisation.crm5.dynamics.com/api/data/v8.2/leads?$select=firstname,leadid',
	    'GET',
	    array(),
	    array('Prefer: odata.maxpagesize=3')
	  );
	} catch ( Exception $e) {
	    throw new SS_HTTPResponse_Exception('failure to connect to crm: '.$e->getMessage());
	}

	try {
	  CRM::request(
	    'https://your_organisation.crm5.dynamics.com/api/data/v8.2/leads(bf830ffd-2047-e711-8105-70106fa91921)',
	    'PATCH',
	    array(
	      "subject" => "123 Website Enquiry",
	      "email  address1" => $do->YourEmail,
	      "firstname" => $do->YourName,
	      "jobtitle" => $do->Message
	    )
	  );
	} catch ( Exception $e) {
	  throw new SS_HTTPResponse_Exception('failure to connect to crm: '.$e->getMessage());
	}

	try {
	  CRM::request(
	    'https://your_organisation.crm5.dynamics.com/api/data/v8.2/leads(bf830ffd-2047-e711-8105-70106fa91921)/subject',
	    'PUT',
	    array(
	      "value" => "321 Website Enquiry"
	    )
	  );
	} catch ( Exception $e) {
	  throw new SS_HTTPResponse_Exception('failure to connect to crm: '.$e->getMessage());
	}

	try {
	  CRM::request(
	    'https://your_organisation.crm5.dynamics.com/api/data/v8.2/leads(bf830ffd-2047-e711-8105-70106fa91921)',
	    'DELETE'
	  );
	} catch ( Exception $e) {
	  throw new SS_HTTPResponse_Exception('failure to connect to crm: '.$e->getMessage());
	}