<?php
$url = "https://www.threads.com/graphql/query";

$cookies = "csrftoken=XYZ123; ds_user_id=74214170932; sessionid=74214170932%3AabcdXYZ123%3A28%3AXYZ12345; mid=YabcdeFgHiJkLmnopQrStUvWxYz";

$headers = [
    "accept: */*",
    "accept-language: en-US,en;q=0.9",
    "content-type: application/x-www-form-urlencoded",
    "x-csrftoken: XYZ123",
    "x-fb-friendly-name: BarcelonaPostViewCountQuery",
    "x-fb-lsd: FRESH_TOKEN",
    "x-ig-app-id: 238260118697367",
    "cookie: $cookies",
    "referer: https://www.threads.com/"
];

// Body with the target postID
$body = "fb_api_req_friendly_name=BarcelonaPostViewCountQuery"
      . "&variables=" . urlencode(json_encode(["postID" => "3725325242667752253"]))
      . "&doc_id=24064370303160092";

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
