예제 #1
0
</center>
</body>
</html>
<?php 
    // You've probably seen this in other servers ;)
    echo str_repeat("<!-- a padding to disable MSIE and Chrome friendly error page -->\n", 6);
    exit;
}
if (!@(include __DIR__ . '/../ProxyHandler.class.php')) {
    sendBadGateWay('Could not load proxy');
}
/* EXPECTED RESPONSE:
{
   "object_or_array": "object",
   "empty": false,
   "parse_time_nanoseconds": <int>,
   "validate": true,
   "size": 1
}
*/
$proxy = new ProxyHandler(array('proxyUri' => 'http://validate.jsontest.com', 'requestMethod' => 'POST', 'data' => 'json=' . json_encode(array('some_key' => 'some_value'))));
// Prevents cURL from hanging on errors
$proxy->setCurlOption(CURLOPT_CONNECTTIMEOUT, 1);
$proxy->setCurlOption(CURLOPT_TIMEOUT, 5);
// Check for a success
if ($proxy->execute()) {
    //print_r($proxy->getCurlInfo()); // Uncomment to see request info
} else {
    sendBadGateWay($proxy->getCurlError());
}
$proxy->close();
예제 #2
0
파일: https.php 프로젝트: chricke/php5rp_ng
<?php

if (!@(include __DIR__ . '/../ProxyHandler.class.php')) {
    die('Could not load proxy');
}
$proxy = new ProxyHandler('https://raw.github.com/chricke/php5rp_ng/master/README.md');
// Prevents cURL from hanging on errors
$proxy->setCurlOption(CURLOPT_CONNECTTIMEOUT, 1);
$proxy->setCurlOption(CURLOPT_TIMEOUT, 5);
// This ignores HTTPS certificate verification, libcurl decided not to bundle ca certs anymore.
// Alternatively, specify CURLOPT_CAINFO, or CURLOPT_CAPATH if you have access to your cert(s)
$proxy->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
// Check for a success
if ($proxy->execute()) {
    //print_r($proxy->getCurlInfo()); // Uncomment to see request info
} else {
    echo $proxy->getCurlError();
}
$proxy->close();