Note: This documentation is outdated, for latest, up-to date documentation please visit:


From HostBill
Jump to: navigation, search

HBWrapper is class written in PHP which can help you a lot using HostBill API. Technically its singleton and wrapps all API functions with simple to call PHP methods. HBWrapper handles API connections and will store your API key and API ID for future usage - so you need only specify them once, no need to remember of adding those to your requests as well as parsing responses every time.

All methods returns arrays if any data is received or boolean if not. Errors and infos received from are being kept in inner arrays for log tracking. It might be also interesting for you that same methods can be called from HB Addon Modules internally using APIWrapper

Latest versions of HostBill wrappers are available here:

Basic usage

Getting HBWrapper instance

  include 'class.hbwrapper.php';
  HBWrapper::setAPI('','API ID','API Key');
  $hbw = HBWrapper::singleton();

Changing API connect url


Full example of basic HBWrapper usage - getting clients list

  include 'class.hbwrapper.php'  
  HBWrapper::setAPI('','API ID','API Key');        //setting connection data
  $hbw = HBWrapper::singleton();                                                       //getting instance of HBWrapper
  $clients = $hbw->getClients();                                                       //receiving client's list

Public methods (w/o api-specific functions)

  • HBWrapper singleton() - get HBWrapper instance
  • void setAPI(string url, string api_id, string api_key) - specify HostBill API url, api id and api key
  • void setAPIUrl(string url) - specify HostBill API url
  • bool LogIn(string username,string password) - log in to HostBill API *
  • bool isLoggedIn() - is current token valid / last login successfull *
  • array getErrors() - get errors ocured during session *
  • array getInfos() - get infos ocured during session *
  • bool selfTest() - check if PHP intallation have all necessary functions for HBWrapper to work (check getErrors if false) *

* Deprecated or made private in HostBill 3.0 and above

Public fields

  • int $timeout - specify timeout for api requests in ms (default: 100)
  • bool $useSession - tells whether to use session to store valid token and dont need to login everytime (default: true) *
  • string $debug_response - stores last server's response for debugging *

* Removed in HostBill 3.0 and above

Personal tools