Get Netsuite Connection


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.