PHP code example of shiftechafrica / net-bill-360-php-sdk

1. Go to this page and download the library: Download shiftechafrica/net-bill-360-php-sdk 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/ */

    

shiftechafrica / net-bill-360-php-sdk example snippets




use NetBill360\NetBill360;

// All SDK methods are called on a new instance of NetBill360
$sdk = new NetBill360();

// Get a list of all supported NAS device types.
// Returns: ["MikroTik", "Cisco", "Huawei", "UBNT Access Point", ...]
$sdk->getNasTypes();

// Get all NAS devices registered in your account
$sdk->getAllNas();

// Add a new NAS device to your account
$sdk->createNas([
    "nasname"     => "192.168.88.109", // IP address of the NAS device
    "type"        => "Huawei",         // Must match one of the supported types
    "secret"      => "secret",         // Shared secret used for authentication
    "port"        => 1812,             // Default RADIUS port
    "description" => "Main HQ NAS"    // Optional human-readable label
]);

// Update an existing NAS device (replace 12 with the actual device ID)
$sdk->updateNas([
    "type"        => "VAS Experts",
    "secret"      => "new_secret",
    "port"        => 1812,
    "description" => "Updated HQ NAS"
], 12);

// Fetch details of a specific NAS device by its ID
$sdk->getNas(12);

// Get Nas Performance metric for connections and packet loss Metrics NAS-Error, User-Request, Lost-Carrier, NAS-Request, NAS-Reboot
$sdk->getNasPerformance([
    "from_date" => "2025-10-27 00:00:00.000", // Start of the period
    "to_date"   => "2025-10-27 23:59:59.000"  // End of the period
],12);

// Permanently remove a NAS device by its ID
$sdk->deleteNas(12);

// List all IP pools in your account
$sdk->getPools();

// Fetch details of a specific IP pool by ID
$sdk->getPool(12);

// Delete an IP pool by ID (use with caution — active IPs may be affected)
$sdk->deletePool(12);

// Get active pppoe connections reports
$sdk->pppoeConnectionReport();

// Check how much data a specific user has consumed in a date range
$sdk->getDataUsage([
    "username"  => "netbill360",
    "from_date" => "2025-10-27 00:00:00.000", // Start of the period
    "to_date"   => "2025-10-27 23:59:59.000"  // End of the period
]);

// Check how much time a specific user has been connected in a date range
$sdk->getTimeUsage([
    "username"  => "netbill360",
    "from_date" => "2025-10-27 00:00:00.000",
    "to_date"   => "2025-10-27 23:59:59.000"
]);

// Get all bandwidth plans
$sdk->getPlans();

// Create a new bandwidth plan
$sdk->createPlan([
    "plan"           => "700Mbps Basic",  // Plan name (shown to admins/customers)
    "download_limit" => 700,              // Download speed in Mbps
    "upload_limit"   => 700,             // Upload speed in Mbps
    "static_ip"      => false,           // Set true if this plan uses a fixed IP address
    "bandwidth_type" => "dedicated",     // "dedicated" = full speed, "shared" = split among users
    "ip"             => "192.0.0.1",     // Required only if static_ip is true
    "devices"        => 1,              // Max devices allowed per PPPoE connection
    "type"           => "pppoe",        // Required pppoe or hotspot or static
    "port_limit"     => 1               // optional only applicable on type hotspot
]);

// Update an existing plan by its ID
$sdk->updatePlan([
    "plan"           => "500Mbps Shared",
    "download_limit" => 500,
    "upload_limit"   => 500,
    "static_ip"      => false,
    "bandwidth_type" => "shared",
    "ip"             => "192.0.0.1",
    "devices"        => 5
    "type"           => "hotspot",    
    "port_limit"     => 1               
], 29); // <-- Plan ID to update

// Get details for a specific plan
$sdk->getPlan(29);

// Delete a plan (make sure no active customers are using it first)
$sdk->deletePlan(29);

// Get all customers in your account
$sdk->getCustomers();

// Create a new customer account
$sdk->createCustomer([
    "plan_id"      => 27,         // The ID of the bandwidth plan to assign
    "username"     => "netbill360",
    "password"     => "securepassword",
    "service_type" => "pppoe",    // "pppoe", "hotspot", or "static"
    "ip_address"   => "",         // Required only if service_type is "static"
    "port_limit"   => 1,          // Required only if service_type is "hotspot"
    "devices"      => 1           // Max simultaneous device connections
]);

// Update an existing customer's details
$sdk->updateCustomer([
    "plan_id"      => 27,
    "username"     => "netbill360",
    "password"     => "newpassword",
    "service_type" => "pppoe",
    "ip_address"   => "",
    "port_limit"   => 1,
    "devices"      => 1
]);

// Get full details for a specific customer by their username
$sdk->getCustomer('netbill360');

// Check if a customer is currently online
$sdk->getCustomerOnlineStatus('netbill360');

// Force-disconnect all active devices/routers for a customer
$sdk->disconnectCustomerDevices('netbill360');

// Get a list of all devices currently connected for a customer
$sdk->connectedCustomerDevices('netbill360');

// Permanently delete a customer account by username
$sdk->deleteCustomer('netbill360');

// List all active and past subscriptions
$sdk->getSubscriptions();

// Create a new subscription for a customer (sets their access expiry date)
$sdk->createSubscription([
    "username" => "netbill360",
    "date"     => "2025-11-30 23:59:59", // Access expires at the end of this date/time
    "timezone" => "Africa/Nairobi", // optional - Use a valid IANA timezone
    "duration_seconds" => 3600 // optional - Only applicable for hot spot sessions and value passed should be in seconds
]);

// Update (extend or change) a customer's subscription expiry
$sdk->updateSubscription([
    "username" => "netbill360",
    "date"     => "2025-12-31 23:59:59", // New expiry date
    "timezone" => "Africa/Nairobi", // optional - Use a valid IANA timezone
    "duration_seconds" => 3600 // optional - Only applicable for hot spot sessions and value passed should be in seconds
]);

// Get a specific customer's subscription details
$sdk->getSubscription('netbill360');

// Remove a subscription (customer will lose access)
$sdk->deleteSubscription('netbill360');

// Get all WireGuard interfaces configured in your account
$sdk->getWireGuardInterfaces();

// Create a new WireGuard VPN interface
$sdk->createWireGuardInterface([
    "name"        => "Office VPN",   // Friendly name for this interface
    "subnet_base" => "10.11.5.0",   // Base IP of the VPN subnet
    "subnet_cidr" => 24,            // Subnet mask (24 = 255.255.255.0)
    "listen_port" => 60000,         // UDP port WireGuard listens on
    "enabled"     => true           // Whether this interface is active
]);

// Update an existing WireGuard interface by its ID
$sdk->updateWireGuardInterface([
    "name"    => "Updated Office VPN",
    "enabled" => true
], 12); // <-- Interface ID

// Fetch details of a specific interface
$sdk->getWireGuardInterface(12);

// Get connection status and activity logs for a specific interface
$sdk->getWireGuardInterfaceStatus(12);

// Get all registered WireGuard peers
$sdk->getWireGuardPeers();

// Register a new peer (client device) on a WireGuard interface
$sdk->createWireGuardPeer([
    "wire_guard_id" => 1,                          // ID of the interface this peer belongs to
    "name"          => "John's Laptop",            // Friendly label for this peer
    "public_key"    => "8chOvnXg/Xl4jDPOmwFSVLddIs8=", // Client's WireGuard public key
    "assigned_ip"   => "10.11.5.2",               // Static IP assigned to this peer within the VPN subnet
    "status"        => true                        // Whether this peer is allowed to connect
]);

// Update an existing peer's configuration by its ID
$sdk->updateWireGuardPeer([
    "name"       => "John's Work Laptop",
    "status"     => true,
    "public_key" => "4iUWTridPn67tVMWLBINn/ZR0lDU6byeVZoPZA4o12I=" // New key if client rotated it
], 12); // <-- Peer ID

// Get full details of a specific peer
$sdk->getWireGuardPeer(12);

// Get the WireGuard config file content for a peer (used to set up the client device)
$sdk->getWireGuardPeerConfig(12);
bash
composer dump-autoload
bash
php artisan vendor:publish --provider="NetBill360\NetBill360ServiceProvider"