"Missing action or provider"]); exit; } // --- BALANCE CHECK --- if ($action === 'balance') { if ($provider === 'smsmobile') { $url = "https://smsmobile.cc/account?username=$smsmobile_username&password=$smsmobile_password"; $response = file_get_contents($url); echo json_encode(["balance" => $response]); } elseif ($provider === 'smsastral') { $data = json_encode([ 'email' => $smsastral_email, 'password' => $smsastral_password ]); $options = [ 'http' => [ 'header' => "Content-Type: application/json", 'method' => 'POST', 'content' => $data, ] ]; $context = stream_context_create($options); $result = file_get_contents("https://client.smsastral.com/api/Api_Balance.php", false, $context); echo $result; } elseif ($provider === 'smsroute') { $url = "https://smsroute.com/api/balance?api_key=$smsroute_user&api_secret=$smsroute_pass"; $response = file_get_contents($url); echo $response; } else { echo json_encode(["error" => "Invalid provider for balance"]); } // --- SEND SMS --- } elseif ($action === 'send') { $number = urlencode($_GET['number'] ?? ''); $message = urlencode($_GET['message'] ?? ''); if (!$number || !$message) { echo json_encode(["error" => "Missing number or message"]); exit; } if ($provider === 'smsmobile') { $url = "https://smsmobile.cc/sendsms?username=$smsmobile_username&password=$smsmobile_password&type=0&source=SMS&destinations=$number&message=$message"; $response = file_get_contents($url); echo json_encode(["response" => $response]); } elseif ($provider === 'smsastral') { $postData = json_encode([ 'email' => $smsastral_email, 'password' => $smsastral_password, 'sender_name' => 'SMS', 'message' => urldecode($message), 'recipients' => [$number] ]); $options = [ 'http' => [ 'header' => "Content-Type: application/json", 'method' => 'POST', 'content' => $postData, ] ]; $context = stream_context_create($options); $result = file_get_contents("https://client.smsastral.com/api/SendSms.php", false, $context); echo $result; } elseif ($provider === 'smsroute') { $url = "https://smsroute.com/api/send?api_key=$smsroute_user&api_secret=$smsroute_pass&to=$number&from=SMS&text=$message"; $response = file_get_contents($url); echo $response; } else { echo json_encode(["error" => "Invalid provider for sending"]); } } else { echo json_encode(["error" => "Invalid action"]); } ?>