150 $token = $this->settings[
"serviceUserToken"];
152 curl_setopt_array($curl, array(
153 CURLOPT_URL => $this->settings[
"domain"] .
"/v2beta/sessions",
154 CURLOPT_RETURNTRANSFER =>
true,
155 CURLOPT_ENCODING =>
'',
156 CURLOPT_MAXREDIRS => 10,
157 CURLOPT_TIMEOUT => 0,
158 CURLOPT_FOLLOWLOCATION =>
true,
159 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
160 CURLOPT_CUSTOMREQUEST =>
'POST',
161 CURLOPT_POSTFIELDS => json_encode($this->request),
162 CURLOPT_HTTPHEADER => array(
163 "Content-Type: application/json",
164 "Accept: application/json",
165 "Authorization: Bearer $token"
169 $response = json_decode(curl_exec($curl));
170 if(isset($response->code)) {
171 throw new Exception(
"Error-Code: " . $response->code .
" Message: " . $response->message);
173 $this->sessionId = $response->sessionId;
174 $this->sessionToken = $response->sessionToken;
175 if (isset($response->challenges->otpSms)) {
176 $this->smsCode = $response->challenges->otpSms;
179 if (isset($response->challenges->otpEmail)) {
180 $this->emailCode = $response->challenges->otpEmail;