final protected function hhmac($string, $api_key_secret) {
    $key = base64_decode($api_key_secret);
    $hashed = hash_hmac('sha256', $string, $key, true);
    $encoded = base64_encode($hashed);
    $signature = rtrim($encoded, "\n");
    return strval($signature);
  }