Created
May 2, 2014 17:31
-
-
Save RobertCalise/6c2003c502e9b685acac to your computer and use it in GitHub Desktop.
Infusionsoft Custom Field Lookup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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