I'm sending a POST request to an API:
$payload = array('body' => $payload);
$payload['redirection'] = false;
$response = wp_remote_post( $settings['webhooks'], $payload );
do_action( 'elementor_pro/forms/webhooks/response', $response, $record );
$redirect_to = wp_remote_retrieve_header( $reponse, 'Location' );
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' );