This version implements a newer version of the xml-rpc handling library. As such, the minimum PHP version has been increased to >= 5.4
Using the composer CLI:
composer require infusionsoft/php-sdk
Or manually add it to your composer.json:
{
"require": {
"infusionsoft/php-sdk": "1.1.*"
}
}
The client ID and secret are the key and secret for your OAuth2 application found at the Infusionsoft Developers website.
require_once 'vendor/autoload.php';
$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());
$infusionsoft->contacts->add(array('FirstName' => 'John', 'LastName' => 'Doe'));
} else {
echo '<a href="' . $infusionsoft->getAuthorizationUrl() . '">Click here to authorize</a>';
}
DateTime objects are now used instead of a DateTime string where the date(time) is a parameter in the method.
$datetime = new \DateTime('now',new \DateTimeZone('America/New_York'));
To enable debugging of requests and responses, you need to set the debug flag to try by using:
$infusionsoft->setDebug(true);
Once enabled, logs will by default be written to an array that can be accessed by:
$infusionsoft->getLogs();
You can utilize the powerful logging plugin built into Guzzle by using one of the available adapters. For example, to use the Monolog writer to write to a file:
use Guzzle\Log\MonologLogAdapter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
$logger = new Logger('client');
$logger->pushHandler(new StreamHandler('infusionsoft.log'));
$infusionsoft->setHttpLogAdapter(new MonologLogAdapter($logger));
$ phpunit
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.