I am trying to make a PHP api for this curl request
curl 'http://xx.74.229.xxx:9200/snapdeal_electronics_mobiles_cat/_search' -d '{ "query": { "match" : { "brand" : "Samsung" } } }'
While executing this in teminal I am getting response, but when I try to use it directly in PHP script , it's not working
<?php
function httpGet($url)
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
// curl_setopt($ch,CURLOPT_HEADER, false);
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
echo httpGet("http://xx.74.229.189:9200/snapdeal_electronics_mobiles_cat/_search' -d '{ "query": { "match" : { "brand" : "Samsung" } } }");
?>
Kindly suggest some solution, it is a get request
httpGetcall has syntax errors. You could useexec, php.net/manual/en/intro.exec.php, and execute your original code or you could full translate it over to use the PHP CURL functionality.