Skip to content

Instantly share code, notes, and snippets.

@RobertCalise
Created May 2, 2014 17:31
Show Gist options
  • Save RobertCalise/6c2003c502e9b685acac to your computer and use it in GitHub Desktop.
Save RobertCalise/6c2003c502e9b685acac to your computer and use it in GitHub Desktop.
Infusionsoft Custom Field Lookup
<?php
// Require Infusionsoft PHP-SDK: https://github.com/infusionsoft/PHP-iSDK
require_once('isdk.php');
$api = new iSDK;
$api->cfgCon('appname');
// What code was entered?
$code = $_POST['code'];
// Query and Return Field arrays
$query = array('_CustomFieldName' => $code);
$return = array('Id');
$contact = $api->dsQuery('Contact', 1, 0, $query, $return);
if(count($contact) == 1) {
$contact_id = (int)$contact[0]['Id'];
// Trigger automation, either with a tag (example Tag ID 123)
// https://developer.infusionsoft.com/docs/read/Contact_Service#addToGroup
$api->grpAssign($contact_id, 123);
// or with an API Completion Goal (Integration: 'customFieldLookup', Call Name: 'codeLookup')
// https://developer.infusionsoft.com/docs/read/Funnel_Service#achieveGoal
$api->achieveGoal('customFieldLookup', 'codeLookup', $contact_id);
} else {
// Do something if no matching contact found. Perhaps a redirect?
header('Location: http://example.com/redirect-path');
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment