PHP code example of estaheri / 3x-ui
1. Go to this page and download the library: Download estaheri/3x-ui library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
estaheri / 3x-ui example snippets
use XUI\Xray\Inbound\Protocols\Vmess\Vmess;
use XUI\Xui;
;
$result = $xui->login($username, $password);
@$response = $result->repsonse;
if ($result->ok && $response->success) {
$xui_inbound = $xui->xray->inbound;
$config = new Vmess();
$config->settings->add_client();
$config->stream_settings->ws_settings(false, '/3x-ui');
$result = $xui_inbound->add($config, 'Test 3x-ui', 100 * Xui::UNIT_GIGABYTE, 86400);
@$response = $result->repsonse;
if ($result->ok && $response->success) {
$inbound_id = $response->obj->id;
var_dump("Inbound added : #$inbound_id");
} else {
$error = $result->error ?? $response->msg;
var_dump("Add inbound failed! (Error: $error)");
}
} else {
$error = $result->error ?? $response->msg;
var_dump("Login failed! (Error: $error)");
}