This is my first attempt to MapQuest and geocoding in general, and it seems that I am not properly passing the url to the API in order to fetch the right coordinates.
This is a reference address:
282 Rosario, Caballito, Ciudad Autonoma de Buenos Aires, Argentina
It returns "-34.618943,-58.432977" on the web map demo, but "-34.59058,-58.5135" with my code.
This is the url I build and pass through a variable:
https://www.mapquestapi.com/geocoding/v1/address?key=<MYKEY>&outFormat=j... Rosario, Caballito, Ciudad Autonoma de Buenos Aires, Argentina&thumbMaps=false
And this is the code I am using to fetch coords with the address inside the "$buildQuery2" variable and then parse the response:
$ch = curl_init(sprintf("$buildQuery2"));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, $buildQuery2);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
$response = curl_exec($ch);
$result = json_decode($response,true);
I do get a response and I do parse it, so the code is doing the request. but I suspect I´m probably not encoding the address or the whole url in the appropiate manner?
I´ve tried serveral variations removing commas, replacing spaces and/or ampersands with the corresponding html codes, etc.
Yet, if I paste my built URL in the browser I get accurate results, so I don´t think I´m too far of getting it to work.
Any help will be appreciated.