I have to send a request to external Api that returns me the redirection page but it is printed on my side as var dump, the dump is the page it i supposed to be redirected to, any help ?
Code :
$url = 'xyz'; try { $response = Drupal::httpClient()->get($url, ['headers' => ['Accept' => 'text/html']]); $data = (string) $response->getBody(); if (empty($data)) { return FALSE; }else{ return $data; } } catch (RequestException $e) { return FALSE; }
Returned $data looks something like this :
<!doctype html> <html lang="en" dir="ltr" class="h-100"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content="asdsad"> <!-- CSRF Token --> <meta name="csrf-token" content="aaaaa1231231"> <title>TEST</title> <link rel="canonical" href="tamal.com"> <!-- Bootstrap core CSS --> <link href="http:xyz.css" rel="stylesheet">