This question is similar to another one answered, however the solution in that case was to use a country code, which is not feasible for this particular use, as the address is being provided by the user through an input field (so a country may not be provided).
Here is the content of my current request
Request coming from AngularJS:
function getCoordinatesFromApi(address) {
            addressApiResponse = $http({
                url: 'php/coordinates.php',
                method: 'get',
                params: {
                    address: address
                },
                headers: {'Content-Type': 'application/x-www-form-urlencoded'}
            });
            return addressApiResponse;
        }
Request handled in PHP:
$api_maps = 'https://maps.googleapis.com/maps/';
$address = urencode($_GET['address']);
$api_key = 'API_key_here';
$url = $api_maps . 'api/geocode/json?address=' . $address . '&key=' . $api_key;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$curl_response = curl_exec($curl);
curl_close($curl);
echo ($curl_response);
When this is called, I consistently get back a valid response with status: 200, but data is an empty string.
I've checked the validity of the $url being build in PHP and it is ok, accessing that url directly in the browser displays a valid API response with data.
I've also tried using Angular's $http method and that too returns a valid response from the API:
function getCoordinatesFromApi(address) {
            addressApiResponse = $http.get('https://maps.googleapis.com/maps/api/geocode/json?address=' + address + '&key=API_key_here');
            return addressApiResponse;
        }
For some reason, it's ony the curl method that does not behave as expected. Has any one dealt with this problem?
 
     
     
     
    