Skip to content

Commit 6ca9bb7

Browse files
cafferatawilldurand
authored andcommitted
remove Google's sensor parameter
The Google API previously required that you include the sensor parameter to indicate whether your application used a sensor to determine the user's location. This parameter is no longer required. - https://developers.google.com/maps/documentation/geocoding/#Sensor
1 parent 8fcfb00 commit 6ca9bb7

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/Geocoder/Provider/GoogleMapsProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class GoogleMapsProvider extends AbstractProvider implements LocaleAwareProvider
2424
/**
2525
* @var string
2626
*/
27-
const ENDPOINT_URL = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false';
27+
const ENDPOINT_URL = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s';
2828

2929
/**
3030
* @var string
3131
*/
32-
const ENDPOINT_URL_SSL = 'https://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false';
32+
const ENDPOINT_URL_SSL = 'https://maps.googleapis.com/maps/api/geocode/json?address=%s';
3333

3434
/**
3535
* @var string

tests/Geocoder/Tests/Provider/GoogleMapsBusinessProviderTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
class GoogleMapsBusinessProviderTest extends TestCase
99
{
10-
private $testClientId = 'foo';
10+
private $testClientId = 'foo';
11+
1112
private $testPrivateKey = 'bogus';
1213

1314
public function testGetName()
@@ -25,8 +26,7 @@ public function testBuildQueryWithNoPrivateKey()
2526
$method->setAccessible(true);
2627

2728
$provider = new GoogleMapsBusinessProvider($this->getMockAdapter($this->never()), $this->testClientId);
28-
29-
$query = 'http://maps.googleapis.com/maps/api/geocode/json?address=blah&sensor=false';
29+
$query = 'http://maps.googleapis.com/maps/api/geocode/json?address=blah';
3030

3131
$this->assertEquals($query.'&client=foo', $method->invoke($provider, $query));
3232
}
@@ -45,9 +45,9 @@ public function testBuildQueryWithPrivateKey()
4545
$this->testPrivateKey
4646
);
4747

48-
$query = 'http://maps.googleapis.com/maps/api/geocode/json?address=blah&sensor=false';
48+
$query = 'http://maps.googleapis.com/maps/api/geocode/json?address=blah';
4949

50-
$this->assertEquals($query.'&client=foo&signature=JY4upbd7fi76C-bMGYk410gmB5g=', $method->invoke($provider, $query));
50+
$this->assertEquals($query.'&client=foo&signature=9G2weMhhd4E2ciR681gp9YabvUg=', $method->invoke($provider, $query));
5151
}
5252

5353
public function testSignQuery()
@@ -64,14 +64,14 @@ public function testSignQuery()
6464
$this->testPrivateKey
6565
);
6666

67-
$query = 'http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France&sensor=false';
67+
$query = 'http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France';
6868

69-
$this->assertEquals($query.'&signature=yd07DufNspPyDE-Vj6nTeI5Fk-o=', $method->invoke($provider, $query));
69+
$this->assertEquals($query.'&signature=7oRS85BVVpPUsyrd4MWFGMJNWok=', $method->invoke($provider, $query));
7070
}
7171

7272
/**
7373
* @expectedException Geocoder\Exception\InvalidCredentialsException
74-
* @expectedExceptionMessage Invalid client ID / API Key https://maps.googleapis.com/maps/api/geocode/json?address=Columbia%20University&sensor=false&client=foo&signature=xhvnqoQoLos6iqijCu3b1Odmqr0=
74+
* @expectedExceptionMessage Invalid client ID / API Key https://maps.googleapis.com/maps/api/geocode/json?address=Columbia%20University&client=foo&signature=9dJq1hPF7_iwafUpnqXUqEkP0gY=
7575
*/
7676
public function testGetGeocodedDataWithInvalidClientIdAndKey()
7777
{
@@ -82,7 +82,7 @@ public function testGetGeocodedDataWithInvalidClientIdAndKey()
8282

8383
/**
8484
* @expectedException Geocoder\Exception\InvalidCredentialsException
85-
* @expectedExceptionMessage Invalid client ID / API Key http://maps.googleapis.com/maps/api/geocode/json?address=Columbia%20University&sensor=false&client=foo&signature=xhvnqoQoLos6iqijCu3b1Odmqr0=
85+
* @expectedExceptionMessage Invalid client ID / API Key http://maps.googleapis.com/maps/api/geocode/json?address=Columbia%20University&client=foo&signature=9dJq1hPF7_iwafUpnqXUqEkP0gY=
8686
*/
8787
public function testGetGeocodedDataWithINvalidClientIdAndKeyNoSsl()
8888
{

tests/Geocoder/Tests/Provider/GoogleMapsProviderTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testGetName()
2020

2121
/**
2222
* @expectedException Geocoder\Exception\NoResultException
23-
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=foobar&sensor=false
23+
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=foobar
2424
*/
2525
public function testGetGeocodedData()
2626
{
@@ -30,7 +30,7 @@ public function testGetGeocodedData()
3030

3131
/**
3232
* @expectedException Geocoder\Exception\NoResultException
33-
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=&sensor=false
33+
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=
3434
*/
3535
public function testGetGeocodedDataWithNull()
3636
{
@@ -40,7 +40,7 @@ public function testGetGeocodedDataWithNull()
4040

4141
/**
4242
* @expectedException Geocoder\Exception\NoResultException
43-
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=&sensor=false
43+
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=
4444
*/
4545
public function testGetGeocodedDataWithEmpty()
4646
{
@@ -80,7 +80,7 @@ public function testGetGeocodedDataWithRealIp()
8080

8181
/**
8282
* @expectedException \Geocoder\Exception\NoResultException
83-
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France&sensor=false
83+
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France
8484
*/
8585
public function testGetGeocodedDataWithAddressGetsNullContent()
8686
{
@@ -90,7 +90,7 @@ public function testGetGeocodedDataWithAddressGetsNullContent()
9090

9191
/**
9292
* @expectedException \Geocoder\Exception\NoResultException
93-
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France&sensor=false
93+
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France
9494
*/
9595
public function testGetGeocodedDataWithAddressGetsEmptyContent()
9696
{
@@ -100,7 +100,7 @@ public function testGetGeocodedDataWithAddressGetsEmptyContent()
100100

101101
/**
102102
* @expectedException \Geocoder\Exception\QuotaExceededException
103-
* @expectedExceptionMessage Daily quota exceeded http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France&sensor=false
103+
* @expectedExceptionMessage Daily quota exceeded http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France
104104
*/
105105
public function testGetGeocodedDataWithQuotaExceeded()
106106
{
@@ -241,7 +241,7 @@ public function testGetGeocodedDataWithRealAddressReturnsMultipleResults()
241241

242242
/**
243243
* @expectedException Geocoder\Exception\NoResultException
244-
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=1.000000%2C2.000000&sensor=false
244+
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=1.000000%2C2.000000
245245
*/
246246
public function testGetReversedData()
247247
{
@@ -271,7 +271,7 @@ public function testGetReversedDataWithRealCoordinates()
271271

272272
/**
273273
* @expectedException \Geocoder\Exception\NoResultException
274-
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=48.863151%2C2.388911&sensor=false
274+
* @expectedExceptionMessage Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=48.863151%2C2.388911
275275
*/
276276
public function testGetReversedDataWithCoordinatesGetsNullContent()
277277
{
@@ -294,7 +294,7 @@ public function testGetGeocodedDataWithCityDistrict()
294294

295295
/**
296296
* @expectedException \Geocoder\Exception\InvalidCredentialsException
297-
* @expectedExceptionMessage API key is invalid http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France&sensor=false
297+
* @expectedExceptionMessage API key is invalid http://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France
298298
*/
299299
public function testGetGeocodedDataWithInavlidApiKey()
300300
{
@@ -326,7 +326,7 @@ public function testGetGeocodedDataWithRealValidApiKey()
326326

327327
/**
328328
* @expectedException \Geocoder\Exception\InvalidCredentialsException
329-
* @expectedExceptionMessage API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=Columbia%20University&sensor=false&key=fake_key
329+
* @expectedExceptionMessage API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=Columbia%20University&key=fake_key
330330
*/
331331
public function testGetGeocodedDataWithRealInvalidApiKey()
332332
{

0 commit comments

Comments
 (0)