File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 12
12
class Geolocation
13
13
{
14
14
// API URL
15
- const API_URL = 'http:// maps.googleapis.com/maps/api/geocode/json ' ;
15
+ const API_URL = 'maps.googleapis.com/maps/api/geocode/json ' ;
16
16
17
- public function __construct ($ api_key = null )
17
+ private $ api_key ;
18
+ private $ https ;
19
+
20
+ public function __construct ($ api_key = null , $ https = false )
18
21
{
19
- $ this ->api_key = $ api_key ;
22
+ $ this ->https = $ https ;
23
+
24
+ if ($ api_key ) {
25
+ $ this ->api_key = $ api_key ;
26
+ $ this ->https = true ;
27
+ }
20
28
}
21
29
22
30
/**
@@ -34,7 +42,7 @@ protected function doCall($parameters = array())
34
42
}
35
43
36
44
// define url
37
- $ url = self ::API_URL . '? ' ;
45
+ $ url = ( $ this -> https ? ' https:// ' : ' http:// ' ) . self ::API_URL . '? ' ;
38
46
39
47
// add every parameter to the url
40
48
foreach ($ parameters as $ key => $ value ) $ url .= $ key . '= ' . urlencode ($ value ) . '& ' ;
You can’t perform that action at this time.
0 commit comments