Friday, February 1, 2019

PHP Toolkit 2012.2 Sample Code: Login

Below is a sample PHP function that invokes login action using 2012.2 PHP toolkit:

(Note: this is assuming input parameters of $nsemail as user email, $nspassword as user password, $nsrole as user role, and $nsaccount as account ID)

function login2($nsemail,$nspassword,$nsrole,$nsaccount){
 $service = new NetSuiteService();
 $loginRequest = new LoginRequest();
 $passport2 = new Passport();
 $passport2->email = $nsemail;
 $passport2->password = $nspassword;
 $passport2->role = $nsrole;
 $passport2->account = $nsaccount;
 $loginRequest->passport = $passport2;
 try{
 $loginResponse = $service->login($loginRequest);
 if (!$loginResponse->sessionResponse->status->isSuccess) {
        echo "Login Failed";
 } else {
  echo "Login Success";
    }}catch(Exception $e){
  echo $e;
 }
}

No comments:

Post a Comment