I am trying to do an automatic post using curl, but the problem is that there is a hidden field that changes its value every time the page is loaded. So I used preg_match_all to capture this value and pass it to the post. The fact is preg_match_all is not returning anything.
This is the piece of code I'm using:
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://www.blidoo.es/pub/');
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch,CURLOPT_HTTPHEADER,array("Accept-Language: es-es,en"));
curl_setopt($ch,CURLOPT_HEADER,false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_PROXYTYPE,'HTTP');
curl_setopt($ch,CURLOPT_PROXYPORT,'5677');
curl_setopt($ch,CURLOPT_PROXY,'192.168.11.16');
curl_setopt($ch,CURLOPT_PROXYUSERPWD,'daemon@AgentOrange.1989');
$result = curl_exec($ch);
$rerror = curl_error($ch);
curl_close($ch);
preg_match_all("(<input type=\"hidden\" name=\"publicar[_csrf_token]\" value=\"(.*)\" id=\"publicar__csrf_token\" />)siU",$result,$matches1);
$return = trim($matches1[1][0]);
I have checked the $result and the string is there. What am I doing wrong?