<?php
/**
 * send_test.php — run from SSH:   php send_test.php 919876543210
 * Or via browser:                 /whatsapp/send_test.php?to=919876543210
 *
 * DELETE THIS FILE once sending works. It is unauthenticated.
 */

require_once __DIR__ . '/wa_api.php';

$to = $argv[1] ?? ($_GET['to'] ?? '');

if ($to === '') {
    exit("Usage: php send_test.php 919582439353\n");
}

header('Content-Type: text/plain');

$result = wa_send_text($to, 'Test from webhook server at ' . date('H:i:s'));

echo "MODE       : " . WA_API_MODE . "\n";
echo "URL        : " . WA_API_URL . "\n";
echo "HTTP code  : " . $result['http'] . "\n";
echo "Message ID : " . ($result['message_id'] ?? '(none returned)') . "\n";
echo "Success    : " . ($result['ok'] ? 'YES' : 'NO') . "\n\n";
echo "Raw response:\n" . $result['body'] . "\n";
