J'ai aussi réussi mais avec sleep avant la simulation du clic bouton
Marche en local mais pas dans le host / Peut-être timeout
private $WAITING_TOKEN_REGEX = '/name=\'waitingToken\'\s*value=\'(.*)\'\s*type=/i';
//renvoie la page apres click
private function ClickButtonFree($LoadCookie, $page)
{
$ret = false;
preg_match($this->WAITING_TOKEN_REGEX, $page, $waitingtokenmatch);
if(!empty($waitingtokenmatch[1]))
{
$this->TAB_REQUEST['waitingToken'] = $waitingtokenmatch[1];
}
sleep(40);
$data = $this->TAB_REQUEST;
$data = http_build_query($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, DOWNLOAD_STATION_USER_AGENT);
if($LoadCookie == true)
{
curl_setopt($curl, CURLOPT_COOKIEFILE, $this->COOKIE_FILE);
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_URL, $this->Url);
$ret = curl_exec($curl);
curl_close($curl);
return $ret;
}