1

I am using maps quest geocoding api to search for zip codes via geocode address api. Request part looks like this:

$ch = curl_init();

// curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);

$return = curl_exec($ch);
curl_close($ch);
$return = json_decode($return);
var_dump($return);

$return looks like this: string(163) "������������,���������������������������������� ������.,17,"

I don't think this service understands my request because other fields in response are empty.

If I paste my request into browser everything works fine. My request looks like this: https://www.mapquestapi.com/geocoding/v1/address?key=API_KEY&location=Москва,Яковоапостольский%20пер.,17,

How to solve this problem?

megagosha
  • 23
  • 1
  • 4
  • Since the request works in a browser and the encoding is commented out, this seems like it could be an url encoding issue. I can't see the result string in my browser. – MQBrian Apr 26 '17 at 14:17

0 Answers0