Is my PHP cURL request malformed because of using a variable in the URL The request works fine when I check it without that Variable. How can i fix it?
<?php
$search_string = $_POST["search_string"];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" . $search_string . "&key=AIzaSyDsb0EFY9lde2EcTYKou3Xrz9ax91qiuTY",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET"
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
echo $response;
}
?>
var_dump($search_string);to confirm the value is what you expect