HTTP プロキシを所有するだけです。
<?php
/**
* Proxy script that performs any HTTP request requested.
*/
// Check key
$key = 'YOUR_API_KEY';
if($_GET['key'] != $key) die; // Check for the API key
// Check URL
$url = isset($_GET['url']) ? trim(base64_decode($_GET['url'])) : '';
if(!$url || !filter_var($url, FILTER_VALIDATE_URL)) die; // Incorrect URL
class MyCurl {
/**
* CURL resource link
*
* @var resource
*/
protected $resource;
/**
* Constructor
*
* @param String $host
* @return MyCurl
*/
public function __construct($url = 'localhost'){
$this->resource = curl_init();
$this->setUrl($url);
$this->setOptions(array(
// CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_AUTOREFERER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_REFERER => 'http://www.google.com/',
CURLOPT_USERAGENT => 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)',
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE,
));
}
/**
* Set URL for the next request
*
* @param String $url
*/
public function setUrl($url = 'localhost') {
$this->setOption(CURLOPT_URL, $url);
}
/**
* Sets option to the CURL resource.
* See http://www.php.net/manual/en/function.curl-setopt.php for option description
*
* @param int $name Option identifier
* @param mixed $value Option value
* @return Crawler_Curl Returns itself for sugar-code
*/
public function & setOption($name, $value){
curl_setopt($this->resource, $name, $value);
return $this;
}
/**
* Sets multiple CURL options at once
*
* @param array $options Associative array of options
* @return Crawler_Curl Returns itself for sugar-code
*/
public function & setOptions($options){
curl_setopt_array($this->resource, $options);
return $this;
}
/**
* Set User-Agent header of the browser
*
* @param String $useragent Defaults to Mozilla browser
*/
public function setUserAgent($useragent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0') {
$this->setOption(CURLOPT_USERAGENT, $useragent);
}
/**
* Get curl request info
*
* @array
*/
public function info() {
return curl_getinfo($this->resource);
}
/**
* Return sent headers if CURLINFO_HEADER_OUT option was enabled
*
* @return String Headers
*/
public function headersSent() {
return curl_getinfo($this->resource, CURLINFO_HEADER_OUT);
}
/**
* Executes CURL request
*
* @return mixed Returns CURL execution result
*/
public function execute(){
return curl_exec($this->resource);
}
/**
* Cleans CURL connection
*/
function __destruct(){
curl_close($this->resource);
}
}
$curl = new MyCurl($url);
$curl->execute();