I want to make an API call with code
<?php
$url = "url";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/xml"));
$data = curl_exec($ch);
echo $data;
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
?>
and hope that the response will be like this
<GoodreadsResponse>
<GoodreadsResponse>
<Request>
<!-- ... request metadata omitted ... -->
</Request>
<search>
<query>
<![CDATA[ Ender's Game ]]>
</query>
<results-start>1</results-start>
<results-end>10</results-end>
<total-results>100</total-results>
<source>Goodreads</source>
<query-time-seconds>0.10</query-time-seconds>
</search>
....
</GoodreadsResponse>
but when I execute that code, it returns in browser like this
true 1 20 386 Goodreads 0.39 2422333 207 690938 33000 1985 4.28 375802 589 Orson Scott Card https://d.gr-assets.com/book ......
How can I fix this