|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Google Map Pro |
|
5
|
|
|
* |
|
6
|
|
|
* @category lib |
|
7
|
|
|
* @author Judicaël Paquet <[email protected]> |
|
8
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
|
9
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
|
10
|
|
|
* @version Release: 1.0.0 |
|
11
|
|
|
* @filesource https://github.com/las93/venus2 |
|
12
|
|
|
* @link https://github.com/las93 |
|
13
|
|
|
* @since 1.0.2 |
|
14
|
|
|
*/ |
|
15
|
|
|
namespace Venus\lib\GoogleMap; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Google Map Pro |
|
19
|
|
|
* |
|
20
|
|
|
* @category lib |
|
21
|
|
|
* @author Judicaël Paquet <[email protected]> |
|
22
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
|
23
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
|
24
|
|
|
* @version Release: 1.0.0 |
|
25
|
|
|
* @filesource https://github.com/las93/venus2 |
|
26
|
|
|
* @link https://github.com/las93 |
|
27
|
|
|
* @since 1.0.2 |
|
28
|
|
|
*/ |
|
29
|
|
|
class Geocoding |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* get the URL with the signature for the Pro account of Google Map |
|
33
|
|
|
* |
|
34
|
|
|
* @access public |
|
35
|
|
|
* @param unknown $sUrlToSign |
|
36
|
|
|
* @param unknown $sClientId |
|
37
|
|
|
* @param unknown $sPrivateKey |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
|
|
public static function signUrlForGoogle(string $sUrlToSign, string $sClientId, string $sPrivateKey) : string |
|
41
|
|
|
{ |
|
42
|
|
|
$aUrl = parse_url($sUrlToSign); |
|
43
|
|
|
$aUrl['query'] .= '&client=' .$sClientId; |
|
44
|
|
|
|
|
45
|
|
|
$aUrlToSign = $aUrl['path']."?".$aUrl['query']; |
|
46
|
|
|
|
|
47
|
|
|
$decodedKey = base64_decode(str_replace(array('-', '_'), array('+', '/'), $sPrivateKey)); |
|
48
|
|
|
|
|
49
|
|
|
$sSignature = hash_hmac("sha1", $aUrlToSign, $decodedKey, true); |
|
50
|
|
|
|
|
51
|
|
|
$sEncodedSignature = str_replace(array('+', '/'), array('-', '_'), base64_encode($sSignature)); |
|
52
|
|
|
|
|
53
|
|
|
$sOriginalUrl = $aUrl['scheme']."://".$aUrl['host'].$aUrl['path'] . "?".$aUrl['query']; |
|
54
|
|
|
|
|
55
|
|
|
return $sOriginalUrl. '&signature='. $sEncodedSignature; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|