Skip to content

Instantly share code, notes, and snippets.

@hassansin
Created June 29, 2015 01:00
Show Gist options
  • Save hassansin/08fd6616b6be2c70f9e3 to your computer and use it in GitHub Desktop.
Save hassansin/08fd6616b6be2c70f9e3 to your computer and use it in GitHub Desktop.
PHP cURL Snippets
/*Use Fiddler Proxy*/
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
/*Use Proxy*/
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, "IP:PORT");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "username:password");
/*SSL Request*/
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
/*Set Headers*/
curl_setopt($process, CURLOPT_REFERER, $referer); // Referere Header
curl_setopt($process, CURLOPT_USERAGENT, $userAgent); // User-Agent Header`
curl_setopt($process, CURLOPT_ENCODING , 'gzip, deflate'); //Accept-Encoding Header
curl_setopt($process, CURLOPT_HTTPHEADER, $headers); // Other Headers
/*Use Cookies*/
$cookie_file = tempnam("/tmp", "cookie")
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment