My goal is to manage my contacts by API. I am using the PHP SDK.
I have a website, I have a CRM, and I want to use infusionsoft for email marketing.
When I push a new lead on my CRM, I want to push the lead to infusionsoft as a new contact, or modify the contact if it already exists. I want this all to happen in the background. Pretty straightforward stuff.
Now, I am trying to implement this and I’m stuck at the access token part. First of all, I don’t fully understand the access token logic because the documentation is weak, to say the least.
I have registered an app on mashery for which I have a clientID and secret.
I go here, hit the API Access link, and I generate an access token and a refresh token: https://accounts.infusionsoft.com/app/central/home
On my script, my understanding is that I first need to create my infusionsoft object as such:
$infusionsoft = new Infusionsoft\Infusionsoft(array(
‘clientId’ => env(‘INFUSIONSOFT_CLIENT_ID’),
‘clientSecret’ => env(‘INFUSIONSOFT_SECRET’),
‘redirectUri’ => env(‘APP_URL’).‘/api/v2/infusionsoft/auth’
));
Then, I need to set a token, as such:
$infusionsoft->setToken($myToken); // here i use the access token I generated
And then I try to use the infusionsoft object to start managing contacts, but I get a not so nice Token Expired Exception. I try again with the refresh token, same problem.
I look for guidance in the PHP SDK, inside the addWithDupCheck.php file, but that basically gets you to use the API to generate an authorization URL, click a button, to generate a code with which you generate an access token, which defeats the purpose of using an API because it requires you to manually click a button.
So, I’m stuck.
(a) can someone explain the logic behind these tokens?
(b) how can I automate token generation to support my use case
(c) what am I doing wrong?