PHP & CURL: step by step – HTTPS Source grabber


Example 3: HTTPS Source grabber

<?php

/**
 * @author tutorialspots.com
 * @copyright 2016
 */

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://demo.tutorialspots.com/sock/gate.php');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 
echo $data = curl_exec($ch);

?>

curl ssl

Result:

a:52:{s:4:"USER";s:5:"nginx";s:4:"HOME";s:11:"/home/nginx";s:9:"FCGI_ROLE";s:9:"RESPONDER";s:15:"SCRIPT_FILENAME";s:57:"/home/nginx/domains/demo.tutorialspots.com/public/sock/gate.php";s:5:"HTTPS";s:3:"off";s:9:"PATH_INFO";s:0:"";s:15:"PATH_TRANSLATED";s:43:"/home/nginx/domains/demo.tutorialspots.com/public";s:12:"QUERY_STRING";s:0:"";s:14:"REQUEST_METHOD";s:3:"GET";s:12:"CONTENT_TYPE";s:0:"";s:14:"CONTENT_LENGTH";s:0:"";s:11:"SCRIPT_NAME";s:14:"/sock/gate.php";s:11:"REQUEST_URI";s:14:"/sock/gate.php";s:12:"DOCUMENT_URI";s:14:"/sock/gate.php";s:13:"DOCUMENT_ROOT";s:43:"/home/nginx/domains/demo.tutorialspots.com/public";s:15:"SERVER_PROTOCOL";s:8:"HTTP/1.1";s:14:"REQUEST_SCHEME";s:4:"http";s:17:"GATEWAY_INTERFACE";s:7:"CGI/1.1";s:15:"SERVER_SOFTWARE";s:12:"nginx/1.9.10";s:11:"REMOTE_ADDR";s:28:"2400:cb00:23:1024::6ca2:df5c";s:11:"REMOTE_PORT";s:5:"57432";s:11:"SERVER_ADDR";s:33:"2001:41d0:a:3171:0:1041:9deb:3a51";s:11:"SERVER_PORT";s:2:"80";s:11:"SERVER_NAME";s:16:"demo.tutorialspots.com";s:18:"GEOIP_COUNTRY_CODE";s:0:"";s:19:"GEOIP_COUNTRY_CODE3";s:0:"";s:18:"GEOIP_COUNTRY_NAME";s:0:"";s:23:"GEOIP_CITY_COUNTRY_CODE";s:0:"";s:24:"GEOIP_CITY_COUNTRY_CODE3";s:0:"";s:23:"GEOIP_CITY_COUNTRY_NAME";s:0:"";s:12:"GEOIP_REGION";s:0:"";s:10:"GEOIP_CITY";s:0:"";s:17:"GEOIP_POSTAL_CODE";s:0:"";s:25:"GEOIP_CITY_CONTINENT_CODE";s:0:"";s:14:"GEOIP_LATITUDE";s:0:"";s:15:"GEOIP_LONGITUDE";s:0:"";s:15:"REDIRECT_STATUS";s:3:"200";s:9:"HTTP_HOST";s:16:"demo.tutorialspots.com";s:15:"HTTP_CONNECTION";s:10:"Keep-Alive";s:20:"HTTP_ACCEPT_ENCODING";s:4:"gzip";s:17:"HTTP_CF_IPCOUNTRY";s:2:"VN";s:20:"HTTP_X_FORWARDED_FOR";s:14:"183.81.119.132";s:11:"HTTP_CF_RAY";s:20:"2b43494f2c12022c-HKG";s:22:"HTTP_X_FORWARDED_PROTO";s:5:"https";s:15:"HTTP_CF_VISITOR";s:18:"{"scheme":"https"}";s:15:"HTTP_USER_AGENT";s:84:"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0";s:11:"HTTP_ACCEPT";s:3:"*/*";s:11:"HTTP_COOKIE";s:52:"__cfduid=dd1a05fbfbd667e9afb2c2d6218b270af1466132643";s:21:"HTTP_CF_CONNECTING_IP";s:14:"183.81.119.132";s:8:"PHP_SELF";s:14:"/sock/gate.php";s:18:"REQUEST_TIME_FLOAT";d:1466132795.2440591;s:12:"REQUEST_TIME";i:1466132795;}<br>a:0:{}<br>a:0:{}<br>

Note:

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Related Post

, ,

No comments yet.

Leave a Reply