Master Branch
Dev Branch
Infusionsoft PHP API - an easy to use version of the PHP Infusionsoft API using GuzzleHTTP.
PHP 7.0 and later
To install the bindings via Composer:
composer require collingmedia/infusionsoft-php-sdk
Getting started is easy, you just have to pass the variables required to use the endpoints you want. For instance, the access token is not required if you are using the authorzation endpoints, but everything is required for any other request.
<?php
$infusionsoft = new CollingMedia\Infusionsoft\Infusionsoft([
'client_id' => '_YOUR_CLIENT_ID_',
'client_secret' => '_YOUR_CLIENT_SECRET_',
'redirect_uri' => '_YOUR_REDIRECT_URI_',
'access_token' => '_YOUR_ACCESS_TOKEN_ARRAY_'
]);
Generate the URLs required, along with retreiving access tokens, and refreshing tokens.
<?php
$infusionsoft = new CollingMedia\Infusionsoft\Infusionsoft([
'client_id' => '_YOUR_CLIENT_ID_',
'client_secret' => '_YOUR_CLIENT_SECRET_',
'redirect_uri' => '_YOUR_REDIRECT_URI_',
]);
This will return the URL required to authroize a user, and redirect them back to your application
$url = $infusionsoft->authorize()->getAuthorizationUrl();
This will exchange the code variable in the URL on a redirect from Infusionsoft for an access token, verifying it against the client_id
, client_secret
, and redirect_uri
.
$code = $_GET['code'];
$token = $infusionsoft->authorize()->getToken($code);
This will refresh the access token you have by sending the refresh code, and getting the response back.
$refreshedToken = $infusionsoft->authorize()->refreshToken();
Get, update, and delete campaigns.
<?php
$infusionsoft = new CollingMedia\Infusionsoft\Infusionsoft([
'client_id' => '_YOUR_CLIENT_ID_',
'client_secret' => '_YOUR_CLIENT_SECRET_',
'redirect_uri' => '_YOUR_REDIRECT_URI_',
'access_token' => '_YOUR_ACCESS_TOKEN_ARRAY_',
]);
This will return all of the campaigns in Infusionsoft, results are paginated.
$campaigns = $infusionsoft->campaigns()->listCampaigns();
This will return the campaign you specify by using the ID.
$campaign = $infusionsoft->campaigns()->getCampaign($campaignId);
Get, update, and delete contacts.
<?php
$infusionsoft = new CollingMedia\Infusionsoft\Infusionsoft([
'client_id' => '_YOUR_CLIENT_ID_',
'client_secret' => '_YOUR_CLIENT_SECRET_',
'redirect_uri' => '_YOUR_REDIRECT_URI_',
'access_token' => '_YOUR_ACCESS_TOKEN_ARRAY_',
]);
This will return all of the contacts in Infusionsoft, results are paginated.
$campaigns = $infusionsoft->contacts()->listContacts();
This will return the contact you specify by using the ID.
$campaign = $infusionsoft->contacts()->getContact($contactId);