<?php
// API credentials
$user = '4w9aAzzbvM';
$pass = 'vHH3NlIMtymQb5MPi0CSUeJxjERdnkNNJkpPu39X';

// API URL (balance check)
$url = 'https://sms.360.my/gw/bulk360/v3_0/balance.php';

// Prepare data
$data = [
    'user' => $user,
    'pass' => $pass
];

// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

// Execute and get response
$response = curl_exec($ch);
curl_close($ch);

// Decode JSON
$result = json_decode($response, true);

// Output balance
if ($result) {
    echo "API Code: " . ($result['code'] ?? 'N/A') . PHP_EOL;
    echo "Description: " . ($result['desc'] ?? 'N/A') . PHP_EOL;
    echo "Balance: " . ($result['balance'] ?? 'N/A') . " " . ($result['currency'] ?? '') . PHP_EOL;
} else {
    echo "Raw Response: " . $response;
}
