/** * @param $params query params - array keys are the names, array values the values. * Values may be arrays. http://php.net/http_build_query is used to build the query. * TODO: http_build_query() may not always be the best way to deal with multi-valued * parameters. Maybe we should implement it here. */ public function setParams($params) { if ($this->url === null) { throw new \InvalidArgumentException('set url first'); } PhpUtil::assertArray($params, 'params'); $this->url .= '?' . http_build_query($params); }
/** * See CURLOPT_POSTFIELDS on http://php.net/curl_setopt . The 'Content-Type' header should * not be set by any other method, cURL will set it to 'multipart/form-data'. * @param $fields array with the field name as key and field data as value. To post a file, * prepend a filename with @ and use the full path as the value. */ public function setFields($fields) { PhpUtil::assertArray($fields, 'fields'); $this->fields = $fields; }
/** * A value in the given array replaces the value for the same key that may have been * set by other methods. If another method set a value for a header key that does not * occur in the given array, that value is not removed or replaced. * @param $headers http headers - array keys are the names, array values the values. */ public function setHeaders($headers) { PhpUtil::assertArray($headers, 'headers'); $this->headers = array_merge($this->headers, $headers); }
/** * @param $params query params - array keys are the names, array values the values. * Values may be arrays. http://php.net/http_build_query is used to build the query. * TODO: http_build_query() may not always be the best way to deal with multi-valued * parameters. Maybe we should implement it here. */ public function setParams($params) { PhpUtil::assertArray($params, 'params'); $this->body = http_build_query($params); }