Geocoder\Provider\GoogleMaps::signQuery PHP Method

signQuery() private method

Sign a URL with a given crypto key Note that this URL must be properly URL-encoded src: http://gmaps-samples.googlecode.com/svn/trunk/urlsigning/UrlSigner.php-source
private signQuery ( string $query ) : string
$query string Query to be signed
return string $query Query with signature appended.
    private function signQuery($query)
    {
        $url = parse_url($query);
        $urlPartToSign = $url['path'] . '?' . $url['query'];
        // Decode the private key into its binary format
        $decodedKey = base64_decode(str_replace(array('-', '_'), array('+', '/'), $this->privateKey));
        // Create a signature using the private key and the URL-encoded
        // string using HMAC SHA1. This signature will be binary.
        $signature = hash_hmac('sha1', $urlPartToSign, $decodedKey, true);
        $encodedSignature = str_replace(array('+', '/'), array('-', '_'), base64_encode($signature));
        return sprintf('%s&signature=%s', $query, $encodedSignature);
    }