1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <?php
$postfields = array();
$postfields["action"] = "...";
$postfields["RoutePost"] = "...";
$postfields["hidRoute1"] = "...";
$postfields["hidRoute2"] = "...";
$postfields["hidRoute3"] = "...";
$postfields["hidRoute4"] = "...";
$postfields["hidNoPax"] = "...";
$postfields["hidCurrency"] = "...";
$postfields["hidHomeURL"] = "...";
$postfields["TripType"] = "...";
$postfields["hidReferComp"] = "...";
$postfields["Route1"] = "...";
$postfields["Route2"] = "...";
$postfields["NoPax"] = "...";
$headers = array();
$headers[0] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$headers[] = "Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3";
$headers[] = "Accept-Encoding: gzip,deflate";
$headers[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$headers[] = "Keep-Alive: 300";
$headers[] = "Connection: keep-alive";
$headers[] = "Content-length:".count($postfields);
//url de la page de soumission
$url = "http://www....";
$useragent = "Mozilla/5.0";
$referer = "http://www....\r\n";
//Initialise une session CURL
$ch = curl_init($url);
//CURL options
//on défini les entetes de la requete http pour lui donner un content-lenght
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//On poste les données du tableau $postfields
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
//On définit un useragent ici Mozilla/5.0
//souvent les bots se font passés pour googlebot ce qui finalement est stupide
//On passe donc un useragent banal
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
//On passe un referrer ici on passe la même page $url
curl_setopt($ch, CURLOPT_REFERER, $referer);
//on récupère le contenu de la page de résultat de la soumission dans une chaine
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Page de résultats et fermeture de session
$result = curl_exec($ch);
curl_close($ch);
//on peut faire un echo du résultat obtenu
echo $result;
?> |
Partager