B
B
BarneyGumble2021-06-23 11:40:26
PHP
BarneyGumble, 2021-06-23 11:40:26

How to get cURL request result like in Raw tab in Postman?

I make a request in Postman The result in the Raw

tab looks like this: And in the Preview tab it looks like this : And when I copy the cURL-PHP code on the right:
ZrJY96ksw5q8OA.jpg


LmGeBYncwNQGEA.jpg

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://my-url',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'property_id%5B%5D=bf7bdcbc-83e5-4fba-b3a9-bc0f97f222f5',
  CURLOPT_HTTPHEADER => array(
    'Content-type: application/x-www-form-urlencoded',
    'Authorization: Basic YzJjN2Q1NTYtMTg2Ny01MmExLTg0ZDYtMzUyMTVlY2Y2ZTUzOjlkMGViNWVjLTdhNTYtNTA4Ny1hODI1LWMyODFhYTEzYzBkYw=='
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo "<pre>";
print_r($response);


then, running this file in the browser, I get the result as in the Preview

tab How to get the response in the browser as in the Raw tab ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2021-06-23
@sslion

htmlspecialchars
but why?

R
Roman Morozov, 2021-10-08
@Q_BASIC

In the browser, click view page code. You display html tags from the response of another server, the browser thinks that this is the layout of your site

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question