Accessing data from php file protected by shield

I have authenticate shield with admin with some password. Now i am unable to search any term in my php file. Earlier it does search using elasticsearch api. Now its display nothing.

In your PHP code are you using the elasticsearch-php client? If so did you configure it to use authentication?

I am not using client.
plz look at this code and where to give authentication ?

$term = $_GET['search'];
$search_host = '';
$search_port = '9200';
$index = 'people';
$doc_type = 'details';
$method = "GET";

$queryData = array('q' => $term) ;
$url =
' http://'.$search_host.':'.$search_port.'/'.$index.'/'.$doc_type.'/_search?'.http_build_query($queryData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT, 9200);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
$result = curl_exec($ch);
$ary = json_decode($result,true);

I am not a PHP developer, so I just did a brief search on how to set authentication and found:

curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);  


1 Like

ya it works.