curl icon indicating copy to clipboard operation
curl copied to clipboard

Error sending array through POST

Open StApostol opened this issue 10 years ago • 0 comments

Hello There was a problem with the method of POST, when I send an array of error takes off. Helps formatting data to be sent via function http_build_query


public function post($url, $data, $params = array(), $debug = false)
{
        $url = $this->buildUrl($url, $params);
        $options = $this->getOptions();
        $options[CURLOPT_POST] = true;
        $options[CURLOPT_POSTFIELDS] = is_array($data) ? http_build_query($data) : $data;
        return $this->exec($url, $options, $debug);
}

StApostol avatar Apr 20 '15 11:04 StApostol