Welcome to the Step by Step manual for the Infusionsoft PHP SDK. This section is meant to be a quick start
guide to get you the information and training you need to use the SDK. We will start off by explaining the SDK and
how to configure it. Once we have it configured we will start off slow creating basic applications gradually
increasing our speed making “real world” applications.
The first thing you will need is a web server that is capable of allowing scripts to communicate with https servers.
A common setup is an apache http server with cURL support compiled in. Most major hosting companies will provide this
for you. One thing to be aware of is if you are using shared hosting instead of a dedicated server you may be behind
a proxy which can complicate connections. The SDKs connection code is written assuming you are not behind a proxy.
The first thing you need to do is upload the SDK to your webserver, you can either upload the entire folder including this
documentation or just the isdk.php file and the conn.cfg file. The isdk.php file is the actual SDK library, the conn.cfg
file is your connections configuration file. The reason for the conn.cfg file is that the SDK is object oriented in the respect
that you can create “application objects” that allow you to communicate with Infusionsoft.
Once you have your SDK uploaded, we need to configure the conn.cfg file(which can also be done before uploading).
The conn.cfg file stores connection data in a colon delimited fashion, each line in this file is a possible connection.
The order in which you build these connections is as follows: Connection name, Application Name, Application Type, API Key, Connection Notes.
A valid entry in the conn.cfg file would look something similar to the line below:
demo:mach2:i:13643d3c89100275607623ed012092b2:This is the connection for mach2.infusionsoft.com |
As you can see, the name of that connection is demo, and it is Referring to an application named mach2, the next section tells us that it is an
Infusionsoft application compared to a Mortgagepro application (i and m are the only valid connection type entries). After the connection type
we have the API Key and following that we just have some notes for the connection line. Some people might look at the notes section and think that it is
pointless, but the reason it is there is so that when an application changes hands the next developer can read notes about each connection. This feature will be especially
useful in situations where companies have more than one license with infusionsoft and similar application names. The notes section also comes in handy when using the
connection builder software so that you can select your connections and see their purpose in life without having to see information like the key.
For now you will have to build your connection lines by hand until the connection builder software is completed. Now that you know how to install and configure the SDK lets go ahead
and learn how to connect to an Infusionsoft application.
You will first start off by including the SDK in your PHP source file. below shows you how to do this assuming your source file is in the same directory as the isdk.php file.
<?php include 'isdk.php'; ?> |
Now that we have included our SDK, we need to create an application object and connect it:
<?php
include 'isdk.php';
$myApp = new iSDK;
if ($myApp->cfgCon("demo")) {
echo "Connected...";
} else {
die("Failed to connect to Infusionsoft!");
}
?>
|
As you can see we create an instance of the iSDK class(myApp), this is now our application object. In the next line we have an if statement that tries to connect us to our “demo” connection.
The cfgCon function returns a boolean value to give you the connection status. So in our code if we successfully connect we will echo “Connected…”. Echoing your connection status isn’t always
desireable so obviously you may leave that part out. Next you can see we have an else on here which will make our application die or exit with a message saying we could not connect.
Now that we have (hopefully) successfully connected we can get started with some actual data manipulation. We will start it off nice and easy in first gear with the “ContactService”. If you haven’t already
now would be a good time to go check it out and what it has to offer. The first task we will do is create a contact in Infusionsoft with the addCon function.
<?php
include 'isdk.php';
$myApp = new iSDK;
if ($myApp->cfgCon("demo")) {
echo "Connected...";
} else {
die("Failed to connect to Infusionsoft!");
}
$conDat = array('FirstName' => 'John',
'LastName' => 'Doe',
'Email' => 'JDoe@email.com');
$conID = $myApp->addCon($conDat);
?>
|
Above you can see we introduce 2 new variables, $conDat and $conId, $conDat is a key/value array, the Key will be your Infusionsoft field name and the value is the value you want it to be.
$conId stores the contacts ID that gets returned when calling the addCon function.
