public static function connect(Infusionsoft_TokenStorageProvider $tokenStorageProvider = null)
 {
     if ($tokenStorageProvider == null) {
         $tokenStorageProvider = Infusionsoft_AppPool::getDefaultStorageProvider();
     }
     $hostName = $tokenStorageProvider->getFirstAppName();
     return Infusionsoft_AppPool::addApp(new Infusionsoft_App($hostName));
 }
<?php

$infusionsoft_host = 'joey.infusionsoft.com';
$infusionsoft_api_key = 'YOUR API KEY GOES HERE';
//To Add Custom Fields, use the addCustomField method like below.
//Infusionsoft_Contact::addCustomField('_LeadScore');
//Below is just some magic...  Unless you are going to be communicating with more than one APP at the SAME TIME.  You can ignore it.
Infusionsoft_AppPool::addApp(new Infusionsoft_App($infusionsoft_host, $infusionsoft_api_key, 443));
<?php

if (session_id() == '') {
    session_start();
}
require_once '../infusionsoft.php';
if (isset($_SESSION['appHostName'])) {
    Infusionsoft_AppPool::addApp(new Infusionsoft_App($_SESSION['appHostName'], $_SESSION['appKey'], $_SESSION['appPort']));
}