<?php ini_set('display_errors', 1); require_once 'libraries/httpProxyClass.php'; require_once 'libraries/cloudflareClass.php'; $httpProxy = new httpProxy(); $httpProxyUA = 'proxyFactory'; $requestLink = 'https://coinkite.com/'; $requestPage = json_decode($httpProxy->performRequest($requestLink)); // if page is protected by cloudflare if ($requestPage->status->http_code == 503) { // Make this the same user agent you use for other cURL requests in your app cloudflare::useUserAgent($httpProxyUA); // attempt to get clearance cookie if ($clearanceCookie = cloudflare::bypass($requestLink)) { // use clearance cookie to bypass page $requestPage = $httpProxy->performRequest($requestLink, 'GET', null, array('cookies' => $clearanceCookie)); // return real page content for site $requestPage = json_decode($requestPage); echo $requestPage->content; } else { // could not fetch clearance cookie echo 'Could not fetch CloudFlare clearance cookie (most likely due to excessive requests)'; } }
// // - SSL Support // - SSL Version Editing // - Custom URL Validation (Regex) // - User Agent Modification // - JSONP Support // - Native Support $httpProxy->global__enableJsonP(); $httpProxy->global__enableNative(); // Header Options // --------------- // raw - raw http headers to send with request // mode - return native, json, or in jsonp // callback - jsonp callback [jsonp mode] // ssl - SSL configuration for request (prevented on standard requests) // host - Allow host verification (1) // peer - Allow peer verification (1) // cert - SSL certificate path // certType - SSL certificate type (defaults to PEM) // version - SSL version number to use // fullStatus - To output full status object with request (1), defaults to only http code // followRedirects - Follow page redirects (1) // maxRedirects - Max page redirects to follow // Get requests // ------------ $jsonRequest = $httpProxy->performRequest('https://www.facebook.com', 'GET'); $jsonpRequest = $httpProxy->performRequest('http://www.facebook.com', 'GET', null, array('mode' => 'jsonp', 'callback' => 'jsonpCallback')); $httpProxy->performRequest('https://www.apple.com', 'GET', null, array('mode' => 'native')); // Post requests // -------------- $postRequest = $httpProxy->performRequest('http://localhost:8888/Personal/Github/httpProxy/test.php', 'POST', array('field1' => 'hello http proxy'));