Posted By

iloveitaly on 07/20/10


Tagged

get connection retrieve netsuite


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

thiswayup


Get Netsuite Connection


 / Published in: PHP
 

Method can that easily used in a PHP class to generate a connection to netsuite. The method below is built using the Kohana library.

  1. protected function getNetsuiteConnection() {
  2. if(empty($this->netsuiteConnection)) {
  3. // setup the netsuite connection
  4. ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.SYSPATH.'vendor/netsuite');
  5.  
  6. require SYSPATH."vendor/netsuite/PHPtoolkit.php";
  7. require SYSPATH."vendor/netsuite/directory_v2009.2.php";
  8.  
  9. $this->netsuiteConnection = new nsClient(nsHost::live);
  10.  
  11. // set request level credentials. (email, password, account#, internal id of role)
  12. $this->netsuiteConnection->setPassport(
  13. Kohana::config('netsuite_email'),
  14. Kohana::config('netsuite_password'),
  15. Kohana::config('netsuite_account'),
  16. Kohana::config('netsuite_role')
  17. );
  18. }
  19.  
  20. return $this->netsuiteConnection;
  21. }

Report this snippet  

You need to login to post a comment.