/** * Creates and returns the appropriate SOAP client for the current version of PHP * * @param void * @return object */ public static function getClient() { // create user object $oUser = new stdClass(); // IF api key is used, add only that to user object if (API == 'PS') { $oUser->sApiKey = API_KEY; } else { $oUser->iId = API_USERNAME; $oUser->sPassword = API_PASSWORD; $oUser->sType = API_USER_TYPE; } // get PHP ver $iPhpVer = str_replace('.', '', phpversion()); // PHP5 (only 5.0.5 onwards has __setSoapHeaders) if (class_exists('SoapClient') && $iPhpVer > 505) { // use PHP5 ext require_once 'class.php5Client.php'; $oClient =& Php5Client::getInstance($oUser); } elseif ($iPhpVer > 505) { die('You are missing the PHP SoapClient. Please re-compile PHP with Soap enabled.'); } else { die('AffiliateWindow APIs will only work with PHP5 and above. Please reinstall'); } return $oClient; }
/** * Singleton function * * @copyright DigitalWindow * @access public * * @param object - $oUser - the user object with login details * * @return object - an instance of the class */ public static function &getInstance($oUser) { $sClassName = __CLASS__; // only create new instance if necessary if (!self::$oInstance) { self::$oInstance = new $sClassName($oUser); } return self::$oInstance; }