-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate.php
More file actions
35 lines (27 loc) · 831 Bytes
/
create.php
File metadata and controls
35 lines (27 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/**
* Code example for creating a user
*/
include '../vendor/autoload.php';
use Gotify\Exception\GotifyException;
use Gotify\Exception\EndpointException;
try {
// Set server
$server = new Gotify\Server('https://gotify.example.com/');
// Set client token
$auth = new Gotify\Auth\Token('TokenHere');
// Create User class instance
$user = new Gotify\Endpoint\User($server, $auth);
// Create a user and get its details
$details = $user->create(
name: 'Bob',
password: 'qwerty1234',
admin: false,
);
// Display user details
echo 'Id: ' . $details->id . PHP_EOL;
echo 'Username: ' . $details->name . PHP_EOL;
echo 'Admin status: ' . $details->admin . PHP_EOL;
} catch (EndpointException | GotifyException $err) {
echo $err->getMessage();
}