Something is missing and I'm not sure what

I think I’ve installed the isdk properly, but I consistently get an error after this code. I’m sure I’m missing a step that I’m not seeing -

Here’s an example of the code:

<?PHP require("vendor/isdk.php"); require_once 'vendor/autoload.php'; $infusionsoft = new Infusionsoft\Infusionsoft(array( 'clientId' => 'ValidID', 'clientSecret' => 'ValidSecret', 'redirectUri' => 'MYURI', )); $yourStoredToken="VALID TOKEN"; // retrieve the existing token object from storage $infusionsoft->setToken($yourStoredToken); $app = new iSDK(); // perform authorization tasks $returnFields = array('Email', 'FirstName', 'LastName'); $conDat = $app->dsLoad("Contact", 123, $returnFields); echo "
".$conDat; The error I get is: Fatal error: Call to a member function send() on a non-object in /****etc/vendor/isdk.php on line 123

Your OAuth is assigned to the object $infusionsoft but your instantiating the app api key method without calling cfgCon method using $app, which is why you are seeing that error message. Pick one method or the other for authentication and only use that object.

That worked, thanks. It needed the cfgCon. But this is the ‘old’ method, is it not?
It doesn’t use the Oauth.

Is this secure?

This is the new method’s code:

And this is the old:

Thanks!
. . . and I assume the new method is more secure since it uses the access_token, is that correct?

I’m still missing something with the new method.
Here is the code I’m using:

<?PHP require_once 'vendor/autoload.php'; $infusionsoft = new Infusionsoft\Infusionsoft(array( 'clientId' => 'MYCLIENTID', 'clientSecret' => 'MYCLIENTSECRET', 'redirectUri' => 'MYREDIRECTURI’, )); $yourStoredToken="MYSTOREDTOKEN"; $infusionsoft->setToken($yourStoredToken); $infusionsoft->contacts->add(array('FirstName' => 'John', 'LastName' => 'DoeXxx')); print_r("
Done! Check records"); ?>

and here’s the error I get:
Fatal error: Uncaught exception ‘Infusionsoft\TokenExpiredException’ in /IS/vendor/infusionsoft/php-sdk/src/Infusionsoft/Infusionsoft.php:385 Stack trace: #0 /IS/vendor/infusionsoft/php-sdk/src/Infusionsoft/Api/ContactService.php(13): Infusionsoft\Infusionsoft->request(‘ContactService…’, Array) #1 /IS/ISTest7.php(22): Infusionsoft\Api\ContactService->add(Array) #2 {main} thrown in /IS/vendor/infusionsoft/php-sdk/src/Infusionsoft/Infusionsoft.php on line 385

I tried getting a new token, but that wasn’t it.

What am I doing wrong?

Sure, but while oauth doesn’t require short time to live with the access token, Infusionsoft requires 24 hour renewal of the token to ensure PCI compliant apps…in short there are pros and cons to both.

1 Like