0

I have 2 CRMs - one is built on Infusionsoft and the other is custom.

I want to synchronize contacts between these 2 CRMS. It is just unidirectional from the custom one to the Infusionsoft one. So when a customer registers at the custom CRM, I want to add his/her info to the Infusionsoft CRM without having the customer realize it =)

Infusionsoft API uses oAuth2 authentication, and this theoretically means "I have to ask the user to enter my username and password for Infusionsoft to get them added to my Infusionsoft CRM" - as far as I understand their API, which is ridiculous.

I do believe what I am trying to do is NOT impossible..... Maybe I am wrong. In worst case, I could use PhantomJS to pass the oAuth authentication. I don't want to use PhantomJS if any other solution exists. I need help from an expert in Infusionsoft. Please advise. Is it possible?

Microtribute
  • 962
  • 10
  • 24

2 Answers2

3

Each Infusionsoft account has an API key that allows you to make calls to the API.

Here are the directions to get the API key for your Infusionsoft application. http://ug.infusionsoft.com/article/AA-00442/0/Infusionsoft-API-Key.html

Once you have the key you can use the PHP SKD to make calls and add contacts. Here is a link to the infusionosft php SDK: https://github.com/infusionsoft/infusionsoft-php

Here is a link to the documentation to add a contact along with a php example: https://developer.infusionsoft.com/docs/xml-rpc/#contact

https://github.com/infusionsoft/API-Sample-Code/blob/master/PHP/ContactService-Sample.php

Edit It looks like they are eventually sunsetting account-level keys in the future which did not require you use to oauth. https://developer.infusionsoft.com/2014/07/03/simplifying-infusionsoft-authentication-with-oauth2/

There are plenty of examples on how to use oauth with Infusionsoft here: https://developer.infusionsoft.com/docs/xml-rpc/#contact

Click PHP on the right hand side and you will see how to get a token and create a contact with the API

There are even more examples on the README in github:

https://github.com/infusionsoft/infusionsoft-php/blob/master/README.md

Authentication:

$infusionsoft = new \Infusionsoft\Infusionsoft(array(
    'clientId'     => 'XXXXXXXXXXXXXXXXXXXXXXXX',
    'clientSecret' => 'XXXXXXXXXX',
    'redirectUri'  => 'http://example.com/',
));

// If the serialized token is available in the session storage, we tell the SDK
// to use that token for subsequent requests.
if (isset($_SESSION['token'])) {
    $infusionsoft->setToken(unserialize($_SESSION['token']));
}

// If we are returning from Infusionsoft we need to exchange the code for an
// access token.
if (isset($_GET['code']) and !$infusionsoft->getToken()) {
    $infusionsoft->requestAccessToken($_GET['code']);
}

if ($infusionsoft->getToken()) {
    // Save the serialized token to the current session for subsequent requests
    $_SESSION['token'] = serialize($infusionsoft->getToken());

    // MAKE INFUSIONSOFT REQUEST
} else {
    echo '<a href="' . $infusionsoft->getAuthorizationUrl() . '">Click here to authorize</a>';
}
joshmmo
  • 1,062
  • 2
  • 13
  • 28
  • 1
    How do you create a token? You're required to be authorized before doing any API call. The API key itself will not help. – Microtribute Dec 05 '15 at 12:57
0

Actually, you do not need to ask your customer for authentication every time in oAuth2. It is only the owner of the application that needs to authenticate once. It does involve storing tokens (either in a database or perhaps a php file), so that you can refresh your tokens, as the tokens expire after 8 hours.

The above code is correct, but it doesn't store the token so you would be needing to authenticate after the session is closed.

http://community.infusionsoft.com/showthread.php/19009-OAuth2-unattended-authentication-process?highlight=storing+token

That is a good link to help get you on the right path that talks about storing tokens for the type of process you want.

David Avellan
  • 385
  • 4
  • 24