Browse Source

fix geocoder and better error handling

main
Aaron Parecki 4 years ago
parent
commit
fe1a5a8c25
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      p3k/Geocoder.php

+ 2
- 2
p3k/Geocoder.php View File

@ -41,7 +41,7 @@ class Geocoder {
public static function geocode($input) {
$response = self::_geocode($input);
if(!$response || count($response->locations) == 0)
if(!$response || !property_exists($response, 'locations') || count($response->locations) == 0)
return false;
$location = $response->locations[0];
@ -106,7 +106,7 @@ class Geocoder {
'outFields' => 'City,Region,Country,Postal',
];
curl_setopt($ch, CURLOPT_URL, 'http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?' . http_build_query($params));
curl_setopt($ch, CURLOPT_URL, 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// curl_setopt($ch, CURLOPT_USERAGENT, '');
curl_setopt($ch, CURLOPT_TIMEOUT, 5);

Loading…
Cancel
Save