Zitadel PHP Client 1.3.6 PHP Client for Zitadel

Loading...
Searching...
No Matches
SMS.php
Go to the documentation of this file.
1<?php
2
3 namespace ZitadelPhpClient\User\SetupTwoFactorAuth;
4
5use Exception;
6
10 class SMS
11{
12 private array $settings;
13 private int $userid;
14
18 public function __construct(array $settings) {
19 $this->settings = $settings;
20 }
21
26 public function setUserId(int $userid) {
27 $this->userid = $userid;
28 }
29
34 public function add() {
35 $this->request("POST");
36 }
37
42 public function remove() {
43 $this->request("DELETE");
44 }
45
51 private function request($type) {
52 $token = $this->settings["userToken"];
53 $curl = curl_init();
54
55 curl_setopt_array($curl, array(
56 CURLOPT_URL => $this->settings["domain"] . "/v2beta/users/$this->userid/otp_sms",
57 CURLOPT_RETURNTRANSFER => true,
58 CURLOPT_ENCODING => '',
59 CURLOPT_MAXREDIRS => 10,
60 CURLOPT_TIMEOUT => 0,
61 CURLOPT_FOLLOWLOCATION => true,
62 CURLOPT_CUSTOMREQUEST => 'POST',
63 CURLOPT_POSTFIELDS =>"{}",
64 CURLOPT_HTTPHEADER => array(
65 "Content-Type: application/json",
66 "Accept: application/json",
67 "Authorization: Bearer $token"
68 ),
69 ));
70
71 $response = json_decode(curl_exec($curl));
72 curl_close($curl);
73 if(isset($response->code)) {
74 throw new Exception("Error-Code: " . $response->code . " Message: " . $response->message);
75 }
76 }
77}
ZitadelPhpClient\User\SetupTwoFactorAuth\SMS
Definition SMS.php:11
ZitadelPhpClient\User\SetupTwoFactorAuth\SMS\setUserId
setUserId(int $userid)
Definition SMS.php:26
ZitadelPhpClient\User\SetupTwoFactorAuth\SMS\add
add()
Definition SMS.php:34
ZitadelPhpClient\User\SetupTwoFactorAuth\SMS\__construct
__construct(array $settings)
Definition SMS.php:18
ZitadelPhpClient\User\SetupTwoFactorAuth
Definition Email.php:3