This PHP application synchronises client and contact data between online data sources, including Harvest and Highrise.
You will need PHP 5+ with CURL and GZIP support. You will also need a scheduling mechanism, such as Cron or Windows Task Scheduler.
To set up FatSync, you will need a basic working knowledge of PHP.
Download the FatSync repository on GitHub
Edit config.php to set up FatSync with your domain names, login details, etc. Each data source will have a different set of required information. In this example, we will set up FatSync to connect to the Highrise online application:
// create a new instance of the highrise data source class:
$highrise = new highrise;
// give your class instance the information it needs to connect to your service:
$highrise->subdomain = 'yourdomain';
$highrise->username = 'yourusername';
$highrise->password = 'yourpassword';
// set additional service-specific options:
$highrise->ssl = true; // enable secure access
$highrise->contact_tag = 'client'; // tag defining contacts as clients
// set sync options for this data source (defaults are always false):
$highrise->sync_additions = true; // items added to this data source will
// be copied to other data sources.
$highrise->sync_updates = true; // chances made to items in this data source
// will be copied to other data sources.
$highrise->sync_deletions = true; // items deleted from this data source will
// also be deleted from other data sources.
// once all options have been set, add this data source to the data source list.
$data_sources[0] = $highrise;
Subsequent data sources should be assigned to $data_sources[1], and so on. When sync conflicts occur (matched records modified on multiple data sources), the order you add them to the $data_sources array will determine which get precedence. For specific setup guides for each data source, see the relevant .txt file.
Run sync.php, either in a web browser, from the command line, or using a task scheduler like Cron.
Because certain web APIs impose limits on how many calls can be made to them in any given timeframe, each time you run sync.php, a different set of records will be examined (starting with whichever records have been waiting the longest). The first time you run it, only client information will be synchronised. Contacts are synchronised on the second and subsequent run.
Clients are paired based on their company name. Contacts are paired based on their email addresses.
Client information that will be synced includes company name and address.
Contact information that will be synced includes first name, last name, email address, mobile, phone number and fax number.
Every addition, update and deletion is logged to the sync.log file. Sync.php also outputs the logged actions, which can be observed in a browser or terminal.
FatSync stores pairing information in a file called local.data, in the same folder as sync.php. Make sure PHP has write access to this folder. You can also delete this local.data file to re-set FatSync pairing, for example, when you add or remove a data source. For security, the local.data file only contains ID and hash information; no actual client/contact data is stored locally.
Init.php sets the PHP maximum execution time to 6 minutes. Depending on the quality of your connection to your data sources, you may need to increase this number. If you prefer to set the time limit to 0 (unlimited), make sure your remote procedures have realistic timeouts. The fs_rest class (base for the bundled harvest and highrise classes) sets the CURL timeout to 10 seconds per call.
When records are deleted from data sources which do not have sync_deletions set to true, FatSync remembers that record and records that it has been deleted, so that it doesn’t get re-created on the next sync. This means that if you recreate that record, it won’t automatically be pair with its old partner records. Instead, new, identical records will be created in other data sources, so that the old pairing remains intact.
For REST data sources (including highrise), using SSL tends to make the sync process considerably slower. If security isn’t a huge consideration for you, you may wish to disable SSL.
If you want to write your own class for a data source, you simply have to implement the fs_data_source class. More information can be found in the class.fs_data_source.php file.
FatSync includes all files inside the modules folder at run-time, so extra classes can be made available simply by leaving them in this folder.
Synchronise other popular API powered applications. Contribute to the FatSync repository on GitHub