<?php
session_start();
require_once __DIR__ . '/../config.php';

echo "<h2>Test Berita Simple</h2>";

$token = $_SESSION['token'] ?? null;
if (!$token) {
    echo "<p>No token found</p>";
    exit;
}

$berita_result = api_get_berita($token);
echo "<h3>API Result:</h3>";
echo "<pre>";
var_dump($berita_result);
echo "</pre>";

if ($berita_result['success']) {
    $data = $berita_result['data'];
    echo "<h3>Data Structure:</h3>";
    echo "<pre>";
    var_dump($data);
    echo "</pre>";

    $items = $data['data'] ?? $data;
    if (is_array($items)) {
        echo "<h3>Items (count: " . count($items) . "):</h3>";
        foreach ($items as $i => $item) {
            echo "<h4>Item $i:</h4>";
            echo "<pre>";
            var_dump($item);
            echo "</pre>";
            echo "<hr>";
        }
    }
}
