My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members

An easy to use Object Oriented php Infusionsoft SDK

This project is now alpha. It has been used in production applications and is very stable.

Requirements

This sdk is designed to run on php 5.1 or greater.

Documentation

Installation

Copy the Infusionsoft directory to your project.

Copy the config.sample.php file to config.php and put in your infusionsoft app hostname and api key.

Add any custom fields you are going to use via the api by adding a line like this to your config.php file.

Infusionsoft_Contact::addCustomField('_LeadScore'); (substitute your Custom Field Name);

Examples

Create a new Contact

include('Infusionsoft/infusionsoft.php');
$contact = new Infusionsoft_Contact();
$contact->FirstName = 'John';
$contact->LastName = 'Doe';
$contact->save();

Load a Contact By Id and Change His Name

include('Infusionsoft/infusionsoft.php');
$contact = new Infusionsoft_Contact($id);
$contact->FirstName = 'John Boy';
$contact->LastName = 'Walton';
$contact->save();

Increment A CustomField called LeadScore

<form>
	ContactId: <input type="text" name="ContactId" value="<?php if(isset($_REQUEST['ContactId'])) echo $_REQUEST['ContactId']; ?>" />
	<input type="submit"/>
</form><br/>
<?php
include('../infusionsoft.php');
if(isset($_REQUEST['ContactId'])){	
	$contact = new Infusionsoft_Contact($_REQUEST['ContactId']);
	$contact->_LeadScore = $contact->_LeadScore + 1;
	$contact->save();
	
	echo 'Lead Score for Contact: ' . $contact->FirstName . ' ' . $contact->LastName . ' is now: ' . $contact->_LeadScore;
} 

Add a value to a CustomField Dropdown

$customField = Infusionsoft_CustomFieldService::getCustomField(new Infusionsoft_Contact(), '_LeadScore');

$customField->addValue('New DropDown Option');
$customField->save();

Query for some data

$contacts = Infusionsoft_DataService::query(new Infusionsoft_Contact(), array('Id' => 2));
$contact = array_shift($contacts);

Create an Order and add a Manual Payment

$contact = new Infusionsoft_Contact();
$contact->FirstName = 'John';
$contact->LastName = 'Doe';
$contact->save();

$invoiceId = Infusionsoft_InvoiceService::createBlankOrder($contact->Id, "An Order", date("Y-m-d H:i:s"));

Infusionsoft_InvoiceService::addOrderItem($invoiceId, $productId, 4, 3.99, 1, 'Order Item', '');
Infusionsoft_InvoiceService::addManualPayment($invoiceId, 3.99, date("Y-m-d H:i:s"), 'API', 'A Manual Payment from the API');

Run an Action Sequence

Infusionsoft_ContactService::runActionSequence($contactId, $actionSetId);

Get all Values for a Custom Field

Only certain custom field types have values. If you try to get the list of values for a custom field that doesn't have values, you will get an exception.

//$customField will be an instance of an Infusionsoft_DataFormField
$customField = Infusionsoft_CustomFieldService::getCustomField(new Infusionsoft_Contact(), '_SomeCustomField');
$fieldValues = $customField->getValues();

Adding a custom field value

Only certain custom field types have values. If you try to add a value to a custom field that doesn't have values, you will get an exception.

//$customField will be an instance of an Infusionsoft_DataFormField
$customField = Infusionsoft_CustomFieldService::getCustomField(new Infusionsoft_Contact(), '_SomeCustomField');
$customField->addValue('Some Value');
$customField->save();

Removing a custom field value

Only certain custom field types have values. If you try to add a value to a custom field that doesn't have values, you will get an exception.

//$customField will be an instance of an Infusionsoft_DataFormField
$customField = Infusionsoft_CustomFieldService::getCustomField(new Infusionsoft_Contact(), '_SomeCustomField');
$customField->removeValue('Some Value');
$customField->save();

Saved Searches

Get all Ids from a saved contact search.

$page = 0;
do{
    $results = Infusionsoft_SearchService::getSavedSearchResults($saved_search_id, $saved_search_user_id, $page, array('Id'));
    $all_ids = array_merge($results, $all_ids);
    $page++;
}while(count($results) > 0);

var_dump($all_ids);
Powered by Google Project Hosting