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 56 57 58 59 60
|
$url = 'https://******************';
$timeout = 10;
$proxy_host = 'PROXY:PROXY_PORT';
$proxy_ident = 'LOGIN:PASSWORD';
$ch = curl_init($url);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
if (preg_match('`^https://`i', $url))
{
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURL_FAILONERROR, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$header);
// Activation de l'utilisation d'un serveur proxy
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
// Définition de l'adresse du proxy
curl_setopt($ch, CURLOPT_PROXY, $proxy_host);
// Définition des identifiants si le proxy requiert une identification
if ($proxy_ident)
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_ident);
$page_content = curl_exec($ch);
// var_dump(curl_getinfo($ch, CURLINFO_HTTP_CODE));
// Vérifie si une erreur survient
if(curl_errno($ch))
{
echo 'Erreur Curl : ' . curl_error($ch);
}
curl_close($ch);
if(!$page_content){
echo "<br><br>Connexion a echoue";
} else {
echo "<br><br>Connexion reussi";
} |
Partager