API_SOAP_TRACE, 'compression'=> SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE) ); // create headers $oHeader = new SoapHeader(API_NAMESPACE, 'UserAuthentication', $oUser, true, API_NAMESPACE); $aHeaders = array($oHeader); // getQuota only used on APIs which do not use a single API Key if (empty($oUser->sApiKey)) { $aHeaders[] = new SoapHeader(API_NAMESPACE, 'getQuota', true, true, API_NAMESPACE); } // set headers $this->__setSoapHeaders($aHeaders); // set WSDL caching ini_set("soap.wsdl_cache_enabled", 1); ini_set('soap.wsdl_cache_ttl', 86400); // set server response timeout ini_set('default_socket_timeout', 240); } /** * 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; } /** * Executes the speficied function from the WSDL * * @copyright DigitalWindow * @access public * * @param string $sFunctionName the name of the function to be executed * @param mixed $mParams [optional] the parameters to be passed to the function, can be array or single value * * @return mixed the results or a SoapError object */ public function call($sFunctionName, $mParams='') { // catch any exceptions try { return $this->$sFunctionName($mParams); } catch(SoapFault $e) { $this->oSoapError = new SoapError($e, $sFunctionName); $error = $this->oSoapError; } return $error; } /** * Gives the remaining operations quota * * @copyright DigitalWindow * @access public * * @return int - the remaining operations quota */ public function getQuota() { $aMatches = array(); $sResponse = $this->__getLastResponse(); // use R.Exp. rather than XML parsers, as they might not be installed preg_match('/getQuotaResponse>(.*)<\/.*:getQuotaResponse>/', $sResponse, $aMatches); $iQuota= $aMatches[1]; return $iQuota; } } // end class