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? https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_security.html#_http_authentication

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

$term = $_GET['search'];
$search_host = '127.0.0.1';
$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);
curl_close($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);  

Source: http://stackoverflow.com/questions/2140419/how-do-i-make-a-request-using-http-basic-authentication-with-php-curl

1 Like

ya it works.
thanks