<?php
// Plain text output, no HTML
header('Content-Type: text/plain');

require_once __DIR__ . '/../config.php';

echo "=== MINIMAL BERITA TEST ===\n\n";

$login = api_login('Widia', 'qwerty5*');
echo "Login: " . ($login['success'] ? 'SUCCESS' : 'FAILED') . "\n";

if ($login['success']) {
    $token = $login['data']['token'];
    $berita = api_get_berita($token);
    echo "Berita API: " . ($berita['success'] ? 'SUCCESS' : 'FAILED') . "\n";
    echo "HTTP Code: " . $berita['http_code'] . "\n";

    if ($berita['success']) {
        $data = $berita['data'];
        echo "Data Type: " . gettype($data) . "\n";
        echo "Data Count: " . (is_array($data) ? count($data) : 'N/A') . "\n";

        if (is_array($data) && !empty($data)) {
            $first = $data[0];
            echo "First Item Keys: " . implode(', ', array_keys($first)) . "\n";
            echo "First Judul: " . ($first['judul'] ?? 'N/A') . "\n";
            echo "First Tanggal: " . ($first['tanggal'] ?? 'N/A') . "\n";
        }
    }
}
