Reputation: 7981
I am getting requests of a service (Beats Service to be specific) where I don't want to expose my client_id. I was able to hide it for everything except for a static image that can be retrieved using a client_id. So, here is the request:
https://partner.api.beatsmusic.com/v1/api/tracks/tr58141709/images/default?client_id=XXXXXXX
when accessing this request, the url redirects to a static image. How can I retrieve the redirected URL without loading the content to my server (I just don't want to do it. It might be a very small overhead since the artwork size is small but I don't want to have it)?
I am using Guzzle as the Http Client for PHP but that is not my main concern because if I understand how this thing works without loading the content, I will be able to enforce what I want to Guzzle.
Upvotes: 0
Views: 357
Reputation: 53988
using curl:
$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'];
}
Upvotes: 1