Hey everyone we’re running into some development issues.
Here is a sample of the code we have created maybe you can spot the issue and let us know we’re going wrong.
the errors are:
Fatal error : Uncaught Infusionsoft\TokenExpiredException
Fatal error : Uncaught Error: Call to a member function getRefreshToken()
Please supply the following sample script to suggest:
============================= Script Sample - 1 ===================================
<?php
if(empty(session_id())) session_start();
require_once '../vendor/autoload.php';
$infusionsoft = new Infusionsoft\Infusionsoft(array(
'clientId' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
'clientSecret' => 'xxxxxxxxxxxxxxxx',
'redirectUri' => 'http://startcloudhost.com/',
));
$contactData = array(
"FirstName" => "John",
"LastName" => "Doe",
"Email" => "john@example.com",
"StreetAddress1" => "123 park",
"City" => "Alabama",
"State" => "AL",
"PostalCode" => "80220",
"CardNumber" => "4242424242424242",
"CVV2" => "123",
"ExpirationMonth" => "11",
"ExpirationYear" => "2021"
);
$dupCheckType = 'Email';
$token = 'UHjVR6aqX4S9W0sN4B7hukwGFl6h';
$_SESSION['token'] = $token;
// 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(($_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()) {
$_SESSION['token'] = serialize($infusionsoft->requestAccessToken($_GET['code']));
}
if ($infusionsoft->getToken()) {
// Save the serialized token to the current session for subsequent requests
$_SESSION['token'] = serialize($infusionsoft->getToken());
$infusionsoft->refreshAccessToken();
// MAKE INFUSIONSOFT REQUEST
$infusionsoft->contacts()->create($contactData);
}
=========================Script - Sample -2 ==========================
<?php
require_once '../vendor/autoload.php';
$infusionsoft = new Infusionsoft\Infusionsoft(array(
'clientId' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'clientSecret' => 'xxxxxxxxxxxxxxxxx',
'redirectUri' => 'http://startcloudhost.com/',
));
$accessToken = 'UHjVR6aqX4S9W0sN4B7hukwGFl6h';
$refreshToken = 'PQtQIGAYGMxbMjScTPgdQRaFNA8HUFXT';
$token = new \Infusionsoft\Token();
$token->setAccessToken($accessToken);
$token->setRefreshToken($refreshToken);
// add token to infusionsoft object
$infusionsoft->setToken($token);
$infusionsoft->contacts()->all();
Any guidance on what is going wrong would be greatly appreciated.
We've reset out API info numerous times to no joy.
Thanks
Our confusion is that the token are working for
$infusionsoft->contacts->add($contactData);
$infusionsoft->contacts()->load($contactId, $selectedFields);
So we can not figure out what is going wrong