I have an issue with libcurl with php. I was sending post data using a string like that:
$post="var1=val1&var2=val2";
curl_setopt($this->ch, CURLOPT_URL, $url);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_POST, 1);
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Accept-Encoding: gzip'));
curl_setopt($this->ch,CURLOPT_ENCODING , "gzip");
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post);
And it worked perfectly, but I would like to change to use an array instead like that:
$post=array();
$post['var1']="val1";
$post['var2']="val2";
curl_setopt($this->ch, CURLOPT_URL, $url);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_POST, 1);
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Accept-Encoding: gzip'));
curl_setopt($this->ch,CURLOPT_ENCODING , "gzip");
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post);
but the server doesn't seems to receive the same thing, is there something I'm missing ?