Ejemplo n.º 1
1
<?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)';
    }
}
Ejemplo n.º 2
0
<?php

require_once 'httpProxyClass.php';
// initialize http service
$httpProxy = new httpProxy();
// Globals
// -------
// You can change permissions and modify the behaviour of the Http Proxy class
// through the use of global methods.
//
// There are quite a few different options which can be customised including:
//
// - 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