Giter Club home page Giter Club logo

infusionsoft-php-sdk's Introduction

Novak Solutions - Infusionsoft PHP SDK

Novak Solutions 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.

Note: This IS NOT the official sdk. The official Infusionsoft created SDK is here: https://github.com/infusionsoft/infusionsoft-php

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

The Infusionsoft PHP SDK is fully supported. If you find a bug or are having problems, submit an issue 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

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

git clone [email protected]: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.

##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);

?>
<pre><?php var_dump($results); ?></pre>

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.

You can also find a bunch of real-world code samples in our GitHub wiki on the Examples page.

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

<?php

require_once('Infusionsoft/infusionsoft.php');

See example.php for a very basic usage example. Additional examples can be found in the Infusionsoft/examples/ folder.

WordPress

If you'd like to use the SDK inside of WordPress or with a WordPress plugin, please use the Infusionsoft SDK plugin. It is listed in the WordPress.org plugin directory so you can easily install it to any WordPress blog. We regularly update this plugin whenever the SDK is updated so you'll always get the latest bug fixes and new features.

Using the Infusionsoft SDK plugin will allow your plugin or custom code to work alongside other plugins that use the Infusionsoft PHP SDK.

License

The Infusionsoft PHP SDK is licensed under the MIT License. It is simple and easy to understand and it places almost no restrictions on what you can do with the SDK.

You are free to use the Infusionsoft PHP SDK in any other project (even commercial projects) as long as the copyright header is left intact.

Details of this license are included in the MIT-LICENSE.txt file, and must be included in all copies of the SDK.

infusionsoft-php-sdk's People

Contributors

joeynovak avatar freezey avatar jacoballred avatar pogden avatar cronoh avatar rickns avatar kinsington avatar erikedpeters avatar pagelab avatar tanishalfelven avatar jchimene avatar calebtr avatar bajax avatar zackkatz avatar odoremieux avatar stevneves avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.