Contact Service
The contact service allows you to add, update and load contacts, as well as add/remove them from groups or campaigns, and run action sequences.
In the SDK you get access to the contact service functions by including the file “ContactService.php” in your code. Below is a list of the functions, their return values and the arguments they accept.
| Function |
Description |
Return Value |
Arguments |
| addCon |
Adds a contact record to Infusionsoft. |
Integer |
1 |
| updateCon |
Updates a contact in Infusionsoft. |
Integer |
2 |
| loadCon |
Loads a contact record from Infusionsoft. |
Array |
2 |
| grpAssign |
Assigns a contact to a group in Infusionsoft. |
Boolean |
2 |
| grpRemove |
Removes a contact from a group in Infusionsoft. |
Boolean |
2 |
| campAssign |
Assigns a contact to a campaign in Infusionsoft. |
Boolean |
2 |
| campRemove |
Removes a contact from a campaign in Infusionsoft. |
Boolean |
2 |
| campPause |
Pauses a campaign for a contact in Infusionsoft. |
Boolean |
2 |
| runAS |
Runs an Action Sequence/Action Set for a specific contact in Infusionsoft. |
Nested Array |
2 |
| getNextCampaignStep |
Returns the id of the next unfinished step in the campaign for the given contact. |
Integer |
2 |
| rescheduleCampaignStep |
Reschedules a campaign step for a list of contacts. |
Integer |
2 |
|
| Top Menu
With the addcon function you can add contact records to the Infusionsoft database. This function is very straight forward, you will just need to create an associative array
of the contact data and pass it as an argument to addCon(). addCon will then create the contact record and return the ID of the newly added contact. Below we have an example of this.
$conDat = array('FirstName' => 'John',
'LastName' => 'Doe',
'Email' => 'JDoe@email.com');
$conID = $myApp->addCon($conDat);
|
|
|
| Top Menu
With the updateCon function to can update fields in a contact record (e.g. a contacts email address). To use this function you just need to create an associative array of the contact data you wish you update, and then call the function passing the contacts ID as the first argument and the array as the second. Below we have an example of how to use this function to update the contacts email address, in this example it is the contact with the ID 123.
$conDat = array('Email' => 'JDoe2@email.com');
$conID = $myApp->updateCon(123, $conDat);
|
updateCon will return an integer that is the ID of the contact you just updated. if the update fails an error will be returned. |
|
| Top Menu
With the loadCon function you can load data from a contacts fields. To do this you just need to specify the contacts ID and an array of the field names in which you wish to pull data from. When you run this function it will return an associative array back to you with the data you requested. Below we have an example of how to load some data from Contact ID 123.
$returnFields = array('Email', 'FirstName', 'LastName');
$conDat = $myApp->loadCon(123, $returnFields);
|
If the function runs without any errors the returned data will look like:
Array
(
[Email] => JDoe@email.com
[FirstName] => John
[LastName] => Doe
)
|
|
|
| Top Menu
with the grpAssign function you can easily add a contact to a group by passing the contact ID and group ID in the arguments of the function. grpAssign will return a boolean value to let you know if the actions succeeded(true) or failed(false). Below we have an example of using the grpAssign function:
$contactId = 123;
$groupId = 456;
$result = $myApp->grpAssign($contactId, $groupId);
|
|
|
| Top Menu
with the grpRemove function you can easily remove a contact from a group by passing the contact ID and group ID in the arguments of the function. grpRemove will return a boolean value to let you know if the actions succeeded(true) or failed(false). Below we have an example of using the grpRemove function:
$contactId = 123;
$groupId = 456;
$result = $myApp->grpRemove($contactId, $groupId);
|
|
|
| Top Menu
With the campAssign function you can add a contact to a campaign by passing the contact ID and the campaign ID. campAssign will return a boolean value to inform you if the action was proccessed successfully or not. Below you will find an example on using the campAssign function:
$contactId = 123;
$campId = 456;
$result = $myApp->campAssign($contactId, $campId);
|
|
|
| Top Menu
With the campRemove function you can remove a contact from a campaign by passing the contact ID and the campaign ID. campRemove will return a boolean value to inform you if the action was proccessed successfully or not. Below you will find an example on using the campRemove function:
$contactId = 123;
$campId = 456;
$result = $myApp->campRemove($contactId, $campId);
|
|
|
| Top Menu
With the campPause function you can pause a contacts campaign steps by passing the contact ID and the campaign ID. campPause will return a boolean value to inform you if the action was proccessed successfully or not. Below you will find an example on using the campPause function:
$contactId = 123;
$campId = 456;
$result = $myApp->campPause($contactId, $campId);
|
|
|
| Top Menu
The runAS function allows you to run an “Action Set” on a contact record. Action Sets must be built out inside of Infusionsoft currently and then you can pass the ID of the Action Set to the function along with the contacts ID. The returned value is a nested array with details about each action in the set. Below is a sample of the function:
$contactId = 123;
$actionId = 456;
$result = $myApp->runAS($contactId, $actionId);
|
Below is an example of the returned array.
Array
(
[0] => Array
(
[Action] => Send Email
[IsError] =>
[Message] => Email 'TEST' sent successfully
)
[1] => Array
(
[Action] => Add/Remove From Group
[IsError] =>
[Message] => Contact added to contact groups: TEST GROUP
)
[2] => Array
(
[Action] => Cancel Recurring Order
[IsError] => 1
[Message] => There are no active recurring orders for 'TEST PROGRAM'
)
)
|
|
|
| Top Menu
The getNextCampaignStep function will return back the next campaign step for a specified contact and campaign.
$cStep = $app->getNextCampaignStep(123,2);
|
|
|
| Top Menu
The rescheduleCampaignStep function is used to reschedule a campaign step for a list of contacts. The return value is the number of the contacts that were successfully added.
$conIds = array(123,456,789);
$numCons = $app->rescheduleCampaignStep($conIds, 23);
|
|