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
| <?php
$lien1 = 'http://urlduformulaire.login.com';
$postfields = array
(
'nomchamp1' => 'valeurlogin',
'nomchamp2' => 'valeurpass'
);
$path_cookie = 'connexion_temporaire.txt';
if (!file_exists(realpath($path_cookie))) touch($path_cookie);
$ch = curl_init($lien1);
curl_setopt($ch, CURLOPT_URL, $lien1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath($path_cookie));
$result = curl_exec($ch);
echo $result;
curl_close($ch);
?> |
Partager