PHPackages                             novaksolutions/infusionsoft-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. novaksolutions/infusionsoft-php-sdk

ActiveLibrary[API Development](/categories/api)

novaksolutions/infusionsoft-php-sdk
===================================

A better Infusionsoft SDK for PHP

6959.5k↓48.7%52[6 issues](https://github.com/novaksolutions/infusionsoft-php-sdk/issues)[1 PRs](https://github.com/novaksolutions/infusionsoft-php-sdk/pulls)PHP

Since Sep 11Pushed 1y ago19 watchersCompare

[ Source](https://github.com/novaksolutions/infusionsoft-php-sdk)[ Packagist](https://packagist.org/packages/novaksolutions/infusionsoft-php-sdk)[ RSS](/packages/novaksolutions-infusionsoft-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (12)Used By (0)Security (1)

Novak Solutions - Infusionsoft PHP SDK
======================================

[](#novak-solutions---infusionsoft-php-sdk)

[Novak Solutions](https://novaksolutions.com/?utm_source=github&utm_medium=readme&utm_campaign=homepage) created our *Infusionsoft PHP SDK* to make it easier to develop for the Infusionsoft platform. The SDK utilizes the Infusionsoft API, but works around some of its [known gotchas](https://blog.novaksolutions.com/infusionsoft-api-gotchas/?utm_source=github&utm_medium=readme&utm_campaign=gotchas).

**Note: This IS NOT the official sdk.** The official Infusionsoft created SDK is here:

Why use our SDK instead of the official one?
--------------------------------------------

[](#why-use-our-sdk-instead-of-the-official-one)

- **No bloated dependencies.** We had no dependencies but we recently added ForceUTF8, If your server has PHP and cURL, and you can add the ForceUTF8 dependency using composer then you are good to go!
- **Code completion.** We've added all the necessary PHPDoc comments so code completion will work in popular editors, like Eclipse and PhpStorm.
- **Automatically retries.** Automatically retries failed API calls when it is safe to do so (i.e., updates and deletes).
- **Automatically handles XML-RPC.** Your requests and responses are automatically encoded and decoded.
- **Automatically picks the right method.** Saving records is easier. The SDK will automatically pick whether to do an insert or an update based on whether you are working with a new or existing record.
- **Future safe!** The SDK will keep working, even if Infusionsoft removes a field in the future.

Fully Supported
---------------

[](#fully-supported)

The *Infusionsoft PHP SDK* is fully supported. If you find a bug or are having problems, [submit an issue](https://github.com/novaksolutions/infusionsoft-php-sdk/issues) and we'll fix it.

We also appreciate community contributions. To contribute: fork the SDK repo, make your changes, and submit a pull request.

Installation
------------

[](#installation)

We keep the `master` branch production ready. To install, simply clone the SDK into a convenient folder. For example:

```
git clone git@github.com:novaksolutions/infusionsoft-php-sdk.git
```

If you get a "Permission denied (publickey)." error, you don't have your github ssh keys setup properly. You can fall back to this:

```
git clone https://github.com/novaksolutions/infusionsoft-php-sdk.git
```

You'll also need to copy `Infusionsoft/config.sample.php` to `Infusionsoft/config.php`. Edit this file and add your app name and [API key](http://ug.infusionsoft.com/article/AA-00442).

\##OAuth2 Usage

The following example code shows how to authenticate using OAuth2. This will automatically save your access and refresh tokens to the current directory in a file called infusionsoft-tokens.php. We store it in a php file that is empty except for a comment so that no one can access this file on your server unless you aren't running php.

```
// This makes troubleshooting MUCH easier during testing. Remove these lines in production.
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Load Infusionsoft
require 'Infusionsoft/infusionsoft.php';

// Load config file (copy config.sample.php to config.php and put your clientid (key) and secret in.
require 'config.php';

// Sets the redirect url to the current url
Infusionsoft_OAuth2::$redirectUri = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

// When this is called, it will process the authentication response, convert the OAuth2 GET params to your access and refresh tokens.  And then save them.
Infusionsoft_OAuth2::processAuthenticationResponseIfPresent();

// If you don't specify a hostname, connect() will load the hostname automatically from the saved file.  Note, this library does support multiple apps, so, if you authenticate to more then one app, you really should specify the app to connect to.
$app = Infusionsoft_App::connect();

// If we just got back from the OAuth page...
if(!$app->hasTokens()){
    header("Location: " . Infusionsoft_OAuth2::getAuthorizationUrl()); //Send To OAuth Page...
    die();
}

$results = Infusionsoft_DataService::query(new Infusionsoft_Contact(), array('FirstName' => '%'), 2);

?>

```

Legacy API Key Usage
--------------------

[](#legacy-api-key-usage)

To help you get started, we've created a screencast that will walk you through using the SDK to create a contact in your Infusionsoft app. You can find the video on YouTube: [Using the Novak Solutions SDK with the Infusionsoft API](http://youtu.be/I4NvbIKrE1E).

You can also find a bunch of real-world code samples in our GitHub wiki on the [Examples](https://github.com/novaksolutions/infusionsoft-php-sdk/wiki/Examples) page.

Your project will need to include `Infusionsoft/infusionsoft.php`, a bootstrapper that automatically loads any classes that are needed. For example:

```
