public static function urlEncode ($parms) {
    $payload = array();

    foreach ($parms as $key => $value) {
      if (is_array($value)) {
        foreach ($value as $item) {
          $payload[] = urlencode($key) . '=' . urlencode($item);
        }
      } else {
        $payload[] = urlencode($key) . '=' . urlencode($value);
      }
    }

    return implode('&', $payload);
  }