<?php
// direct_debug.php
$phone = "249918194952";
$message = "اختبار مباشر";

$api_token = "11|lztDoMxzMfbkuNAL8nCFAGdftW0CtkrHxiU0qIBAbf1c0331";
$sender_id = "UOFT";
$url = "https://sms.brqsms.com/api/http/sms/send";

$data = [
    'recipient' => $phone,
    'sender_id' => $sender_id, 
    'message' => $message,
    'api_token' => $api_token
];

echo "<h3>SMS Debug Info:</h3>";
echo "Phone: " . $phone . "<br>";
echo "Message: " . $message . "<br>";
echo "URL: " . $url . "<br>";
echo "Data: <pre>" . print_r($data, true) . "</pre>";

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => http_build_query($data),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 10
]);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);

echo "<h3>Response:</h3>";
echo "HTTP Code: " . $http_code . "<br>";
echo "cURL Error: " . $error . "<br>";
echo "Response: <pre>" . htmlspecialchars($response) . "</pre>";

if (strpos($response, 'success') !== false) {
    echo "<h3 style='color:green'>SMS SUCCESS!</h3>";
} else {
    echo "<h3 style='color:red'>SMS FAILED!</h3>";
}