Skip to content

Instantly share code, notes, and snippets.

@iaintshine
Created June 12, 2015 09:55
Show Gist options
  • Save iaintshine/fc8406765626d37063f6 to your computer and use it in GitHub Desktop.
Save iaintshine/fc8406765626d37063f6 to your computer and use it in GitHub Desktop.
Sample usage of Base CRM high-level Sync API wrapper
<?php
require 'vendor/autoload.php';
function getAccessToken()
{
$token = getenv("BASECRM_ACCESS_TOKEN");
if (!$token) throw new Exception('"BASECRM_ACCESS_TOKEN" environment variable has not been found');
return $token;
}
function getDeviceUUID()
{
$deviceUUID = getenv("BASECRM_DEVICE_UUID");
if (!$deviceUUID) throw new Exception('"BASECRM_DEVICE_UUID" environment variable has not been found');
return $deviceUUID;
}
$client = new \BaseCRM\Client([
'accessToken' => getAccessToken(),
'verbose' => true
]);
$sync = new \BaseCRM\Sync($client, getDeviceUUID());
$sync->fetch(function ($meta, $resource) {
print_r($meta);
print_r($resource);
return \BaseCRM\Sync::ACK;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment