I’m sending a POST request to an API:
$response = wp_remote_post( "www.example.com/redirect_me", $payload );
The API endpoint returns a 302 redirect
to a different URL: www.you-got-redirected.com
.
How can I access www.you-got-redirected.com
as a variable in PHP? I’m aware of wp_remote_retrieve_body
but that’s for the contents, not the URL.
I don’t want to change the behavior of the API, and the documentation for wp_remote_post()
says nothing about how to access the contents of the response.
EDIT: tried this but it always returns empty string
$redirect_to = wp_remote_retrieve_header( $reponse, 'Location' );