Agitez votre trafic avec Oseox, Plus de 400 cours gratuits.
Profitez de nos meilleurs conseils, Recevez notre newsletter pro !
Le passage par un serveur proxy pour effectuer une requête CURL s'effectue via 3 options :
<?php
$url = 'http://www.oseox.fr';
$timeout = 10;
$proxy_host = 'my-proxy.com:80'; // host:port
$proxy_ident = ''; // username:password
$ch = curl_init($url);
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, 0);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 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);
curl_close($ch);
echo $page_content;
?>
Une question ? Venez la poser sur notre forum développement web !