有没有办法在不加载内容的情况下获得重定向 URL?

Is there a way I can get the redirect URL without loading the content?

我收到了一项服务请求(具体来说是 Beats 服务),但我不想公开我的 client_id。除了可以使用 client_id 检索的静态图像外,我能够隐藏所有内容。所以,这是请求:

https://partner.api.beatsmusic.com/v1/api/tracks/tr58141709/images/default?client_id=XXXXXXX

访问此请求时,url 重定向 到静态图像。如何在不将内容加载到我的服务器的情况下检索重定向的 URL (我只是不想这样做。这可能是一个非常小的开销,因为艺术品尺寸很小但我不想拥有它)?

我正在使用 Guzzle 作为 PHP 的 Http 客户端,但这不是我主要关心的问题,因为如果我了解它的工作原理而不加载内容,我将能够强制执行我想要的 Guzzle .

使用卷曲:

$url = 'https://partner.api.beatsmusic.com/v1/api/tracks/tr58141709/images/default?client_id=XXXXXXX';
$ch = curl_init($url);
curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

// check if we've received a redirect in the Location header
if (array_key_exists('redirect_url', $info)) {
        // do something with the Location header value
        echo $info['redirect_url'];
}