<?php
header('Content-Type: application/json; charset=utf-8');

// Get the URL the partner tried to embed
$targetUrl = isset($_GET['url']) ? $_GET['url'] : '';

if (empty($targetUrl)) {
    http_response_code(400);
    echo json_encode(array("error" => "Missing URL parameter"));
    exit;
}

// Build the oEmbed response using the exact URL requested 
// (This automatically includes your subfolder and any model parameters like ?model=W5)
$response = array(
    "version" => "1.0",
    "type" => "rich",
    "provider_name" => "3D Lab IICT BAS",
    "width" => 800,
    "height" => 600,
    "html" => '<iframe src="' . htmlspecialchars($targetUrl) . '" width="100%" height="600px" style="border:none; border-radius:8px;" allowfullscreen></iframe>'
);

echo json_encode($response);
?>