summaryrefslogtreecommitdiff
path: root/bin/create-user
diff options
context:
space:
mode:
Diffstat (limited to 'bin/create-user')
-rwxr-xr-xbin/create-user24
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/create-user b/bin/create-user
new file mode 100755
index 0000000..02cb7da
--- /dev/null
+++ b/bin/create-user
@@ -0,0 +1,24 @@
+#!/usr/bin/env php
+
+<?php
+
+$options = getopt("", ["username:", "password:", "server:"]);
+
+foreach (["username", "password", "server"] as $variable) {
+ if (! array_key_exists($variable, $options)) {
+ die("missing $variable");
+ }
+}
+
+file_get_contents("https://$options[server]/_matrix/client/v3/register", false, stream_context_create([
+ "http" => [
+ "header" => ["Content-Type: application/json"],
+ "method" => "POST",
+ "content" => json_encode([
+ "device_id" => "matrix-php-cli",
+ "inhibit_login" => true,
+ "password" => $options["password"],
+ "username" => $options["username"],
+ ]),
+ ]
+]));