About InfusionSoftDotNet Library

The InfusionSoftDotNet Library is a .Net dll that provides Asp.Net and .Net applications an interface to communicate with the InfusionSoft API. This library's isdnAPI class should very closely mimic the functionality available PHP SDK provided to developers by InfusionSoft. You will need to have a basic familiarity with the InfusionSoft API and the world of InfusionSoft services to make the most use of this library. When coding, please keep in mind their usage guidelines to ensure good performance for us all.

InfusionSoft bills itself as a "Marketing Automation Suite" that includes modules for Permission-based Email Marketing, a fully-integrated CRM, Smart Automation, Real-world Marketing and sales engine. 

The InfusionSoftDotNet Library relies heavily on the XmlRPC library from Cook Computing. The library's Interfaces, isdnAPI class and isdnExtension classes all pass data back and forth using XmlRpcStructures. These easy to use structures are effectively dictionaries that hold an array of key-value pairs. If you need more information about how the Xml-Rpc.net library, you'll find the documentation here. One "gotcha" when working with the XmlRpcStructures and the InfusionSoft API is that if a field is requested to be returned in an XmlRpcStructure and there is no value for that field, the key-value pair will not exist in the returned structure. In future versions we'll take care of this as we roll out common data classes; thereby eliminating the need for a developer to know the details of XmlRpcStructures and how the API returns this data.

Until we add support for Classes for standard data structures (Contact, Tag(ContactGroup), Affiliate, Invoice, etc), you will want to become familiar with the InfusionSoft Database Tables & Fields so you can read and write fields in the various tables.

Using InfusionSoftDotNet Library

To use the InfusionSoftDotNet Libary in your application or web app, you'll need to:

  • Add the InfusionSoftDotNet and Xml-Rpc.net DLLs to your /bin directory or Reference the two DLLs
  • Add the following lines to your web.config or app.config file in the <appSettings> node:
    • <add key="iSdk-AppName" value="NAME"/> where NAME is the name of your InfusionSoft application (ie: https://name.infusionsoft.com/)
    • <add key="iSdk-AppType" value="AppType"/> where AppType is either i or m depending on whether the application is an InfusionSoft (most likely) or MortgageProCRM app  
    • <add key="iSdk-ApiKey" value="ApiKey"/> where ApiKey is the Encrypted Key for your application as found in Setup | Misc Settings | Miscellaneous tab. If an Encrypted Key isn't listed, you'll need to provide an API Passphrase to generate one.  

C# Example:

using ...normal System classes...;
using CookComputing.XmlRpc;
using InfusionSoftDotNet;


public partial class TestInfusionSoftAPI : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        string echoString = "Hello InfusionSoft!";
        Response.Write(String.Format("isdnAPI.appEcho(\"{1}<br />\") returns: {0} \n",
            isdnAPI.appEcho(echoString),
            echoString));

        // return the Id of the first occurrence of given email address in InfusionSoft application database
        string email = "name@domain.com";
        Response.Write(String.Format("isdnAPI.findByEmail(\"{1}\") returns: {0} (Note: this is the first value; system could return multiple records)<br />",
            GetIdFromEmail(email).ToString(),
            txtEmail.Text));

        // return a value indicating the opt-in status of the first email address returned by isdnAPI.findByEmail()
        // values could be 0 (not opted in), 1 (single opt-in) or 2 (double opt-in)
        Response.Write(String.Format("isdnAPI.getOptStatus(\"{1}\") returns: {0} <br />",
            isdnAPI.getOptStatus(email),
            txtEmail.Text));

        // Test adding contact. Returns the Id of the newly created user or -1 on failure
        XmlRpcStruct Contact = new XmlRpcStruct();
        Contact.Add("FirstName", "Joe");
        Contact.Add("LastName", "Cool");
        Contact.Add("Email", "email@domain.com");
        Contact.Add("ContactType", "Prospect");
        Response.Write(String.Format("isdnAPI.add(\"Contact\") returns: {0} <br />",
            isdnAPI.add(Contact).ToString()));


    }

    protected Int32 GetIdFromEmail(string email)
    {
        string resultsString = string.Empty;
        string[] returnFields = { "Id" };
        XmlRpcStruct[] results = isdnAPI.findByEmail(email, returnFields);
        if (results.Length > 0)
            return Convert.ToInt32(results[0]["Id"]);
        else
            return -1;
    }
}

Classes/Interfaces

Last edited Dec 16, 2010 at 7:47 AM by mjg, version 7

Comments

No comments yet.