I have some input i am getting from a client and posted to teh server via ajax.
A ample of such data is
Woodvale Grove, Nairobi, Kenya| Garissa| Mombasa Road
I am using php and i am then making this request with my key
$pickup = $this->input->post('pick');
$destination = $this->input->post('dest');
$user_id = $this->input->post('user_id');
$additional_destinations = $this->input->post('more_dests');
echo $additional_destinations;
$json = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=".$pickup."&destinations=".$additional_destinations."&mode=driving&key=hidden");
$distance_arr = json_decode($json);
echo $distance_arr;
I get an error 400 and this is the error
Severity: Warning
Message: file_get_contents(https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=Duma Road, Nairobi, Kenya&destinations=Woodvale Grove, Nairobi, Kenya| Garissa| Mombasa Road&mode=driving&key=hidden): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
I copied the link in the error and noticed that the key is not being recognised or read.
How should i fix this?.