<?php

$url = 'https://0...content-available-to-author-only...r.org/sora/81172482/d3NObUFoMm54NkgrQThhbGg2V1NRUGNyY2x4cktxd0dBZjhTWlZIaWppR2NJVzBv';

$ch = curl_init($url);

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER  => true,
    CURLOPT_FOLLOWLOCATION  => true,
    CURLOPT_HTTPHEADER      => [
        'Referer: https://p...content-available-to-author-only...x.com',
    ],
    CURLOPT_SSL_VERIFYPEER  => true,
    CURLOPT_USERAGENT       => 'curl/7.76.1',
    CURLOPT_CONNECTTIMEOUT  => 10,
    CURLOPT_TIMEOUT         => 15,

    // Abort as soon as we start receiving the body
    CURLOPT_NOPROGRESS      => false,
    CURLOPT_PROGRESSFUNCTION => function($ch, $dlTotal, $dlNow, $ulTotal, $ulNow) {
        // Once headers are done and body starts, abort
        if ($dlTotal > 0 || $dlNow > 0) {
            return 1; // Returning non-zero aborts the transfer
        }
        return 0;
    },
]);

curl_exec($ch);

// CURLE_ABORTED_BY_CALLBACK (42) is expected — not a real error
$errno = curl_errno($ch);
if ($errno && $errno !== 42) {
    die('cURL error (' . $errno . '): ' . curl_error($ch));
}

$finalurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

curl_close($ch);

echo $finalurl . PHP_EOL;
?>
