<?php
header('Content-Type: application/json');

// Konfigurasi API
$log_url = "http://fetch.336699bet.com/markArchieve.ashx"; 
$operator_code = "m44i";
$secret_key = "073d2ea5b1455c56a44f48899b9bb5f6";

$signature = strtoupper(md5($operator_code . $secret_key));

$data = [
    "operatorcode" => $operator_code,
    "signature" => $signature,
    "ticket" => "46360208558,46360187669"
];

$json_data = json_encode($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $log_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Content-Length: ' . strlen($json_data)
]);

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

// Cek respons API
if ($http_code == 200) {
    echo json_encode(json_decode($response, true), JSON_PRETTY_PRINT);
} else {
    echo json_encode([
        "error" => "Gagal mengirim data ke API",
        "http_code" => $http_code,
        "curl_error" => $error_msg
    ], JSON_PRETTY_PRINT);
}
?>
