PHP code example of basecrm / basecrm-php

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

    

basecrm / basecrm-php example snippets






// Then we instantiate a client (as shown below)

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);
$client->deals; // \BaseCRM\DealsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);
$client->deals->all(['organization_id' => google['id'], 'hot' => true]);

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);
$client->deals->get($id) # => array

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);
$deal = $client->deals->create(['name' => 'Website redesign', 'contact_id' => $id]);

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);
$client->deals->destroy($id) // => true

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);
$lead = $client->leads->create(['organization_name' => 'Design service company']);

$lead['website'] = "http://www.designservices.com"
$client->leads->update($lead['id'], $lead);

try
{
  // Instantiate a client.
  $client = new \BaseCRM\Client(['accessToken' => getenv('BASECRM_ACCESS_TOKEN')]);
  $lead = $client->leads->create(['organization_name' => 'Design service company']);

  print_r($lead);
}
catch (\BaseCRM\Errors\ConfigurationError $e)
{
  // Invalid client configuration option
}
catch (\BaseCRM\Errors\ResourceError $e)
{
  // Resource related error
  print('Http status = ' . $e->getHttpStatusCode() . "\n");
  print('Request ID = ' . $e->getRequestId() . "\n");
  foreach ($e->errors as $error)
  {
    print('field = ' . $error['field'] . "\n");
    print('code = ' . $error['code'] . "\n");
    print('message = ' . $error['message'] . "\n");
    print('details = ' . $error['details'] . "\n");
  }
}
catch (\BaseCRM\Errors\RequestError $e)
{
  // Invalid query parameters, authentication error etc.
}
catch (\BaseCRM\Errors\Connectionerror $e)
{
  // Network communication error, curl error is returned
  print('Errno = ' . $e->getErrno() . "\n");
  print('Error message = ' . $e->getErrorMessage() . "\n");
}
catch (Exception $e)
{
  // Other kind of exception
}

$client = new \BaseCRM\Client(['access_token' => '<YOUR_PERSONAL_ACCESS_TOKEN>']);
$sync = new \BaseCRM\Sync($client, '<YOUR_DEVICES_UUID');

$sync->fetch(function ($meta, $data) {
  $options = [
    'table' => $meta['type'],
    'statement' => $meta['sync']['event_type'],
    'properties' => $data
  ];
  return \DAO::execute($options) ? \BaseCRM\Sync::ACK : \BaseCRM\Sync::NACK;
});

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->accounts // => \BaseCRM\AccountsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->associatedContacts // => \BaseCRM\AssociatedContactsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->contacts // => \BaseCRM\ContactsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->deals // => \BaseCRM\DealsService

$deal['value'] = 10;
$deal['value'] = 10.10;
$deal['value'] = "10.10";

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->dealSources // => \BaseCRM\DealSourcesService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->leads // => \BaseCRM\LeadsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->leadSources // => \BaseCRM\LeadSourcesService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->lineItems // => \BaseCRM\LineItemsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->lossReasons // => \BaseCRM\LossReasonsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->notes // => \BaseCRM\NotesService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->orders // => \BaseCRM\OrdersService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->pipelines // => \BaseCRM\PipelinesService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->products // => \BaseCRM\ProductsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->sources // => \BaseCRM\SourcesService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->stages // => \BaseCRM\StagesService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->tags // => \BaseCRM\TagsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->tasks // => \BaseCRM\TasksService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->textMessages // => \BaseCRM\TextMessagesService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->users // => \BaseCRM\UsersService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->visits // => \BaseCRM\VisitsService

$client = new \BaseCRM\Client(['accessToken' => '<YOUR_PERSONAL_ACCESS_TOKEN>');
$client->visitOutcomes // => \BaseCRM\VisitOutcomesService
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
bash
composer 
bash
$ BASECRM_ACCESS_TOKEN=<your-token-here> ./vendor/bin/phpunit --filter testUpdate tests/LeadsServiceTest.php