X-Git-Url: https://git.cweiske.de/shpub.git/blobdiff_plain/03c6c0364363b228d1f651a881c36017099dda9d..702a671539587fc1ad89258e8c3eb5cf006428b4:/src/shpub/Request.php diff --git a/src/shpub/Request.php b/src/shpub/Request.php index 44894c5..0924dda 100644 --- a/src/shpub/Request.php +++ b/src/shpub/Request.php @@ -53,6 +53,21 @@ class Request return $this->req->addUpload($fieldName, $filename); } + /** + * Add one or multiple POST parameters. + * Automatically adds them as array or as string. + * + * @param string $key Parameter name + * @param string|array $values One or multiple values + */ + public function addPostParameter($key, $values) + { + if (count($values) == 1) { + $values = reset($values); + } + $this->req->addPostParameter($key, $values); + } + protected function printCurl() { $command = 'curl'; @@ -68,7 +83,15 @@ class Request if (count($this->uploadsInfo) == 0) { foreach ($postParams as $k => $v) { - $command .= ' -d ' . escapeshellarg($k . '=' . $v); + if (!is_array($v)) { + $command .= ' -d ' . escapeshellarg($k . '=' . $v); + } else { + foreach ($v as $ak => $av) { + $command .= ' -d ' . escapeshellarg( + $k . '[' . $ak . ']=' . $av + ); + } + } } } else { foreach ($postParams as $k => $v) {