function httpRequest ($url, $postData = false)
{
$ch = curl_init();
//設定逾時
curl_setopt($ch, CURLOPT_TIMEOUT, );
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if ($postData) {
curl_setopt($ch, CURLOPT_POST, );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
}
$header = [
'CLIENT-IP:'. getIp(),
'X-FORWARDED-FOR:'.getIp(),
];
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_REFERER, "http://www.10086.cn/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
function getIp()
{
return mt_rand(, ) . '.' . mt_rand(, ) . '.' . mt_rand(, ) . '.' . mt_rand(, );
}
浏覽器 chrome console 調試神器
加入jquery
;(function(d, s){d.body.appendChild(s = d.createElement('script')).src = 'http://code.jquery.com/jquery-1.9.1.min.js'})(document,null);
$_GET 處理get方式傳回的數值
$_POST 處理post方式傳回的數值
$GLOBALS["HTTP_RAW_POST_DATA"] 處理xml方式傳回的數值
因為傳回的數組,您可以通過serialize() 進行序列化
// 請求log
我自己寫的一些函數
$requestUrl = date('Y-m-d H:i:s', time()) . PHP_EOL;
$requestUrl .= "<<<<<<<<<<XML>>>>>>>" . PHP_EOL . serialize($GLOBALS["HTTP_RAW_POST_DATA"]) . PHP_EOL;
$requestUrl .= "<<<<<<<<<<POST>>>>>>>" . PHP_EOL. serialize($_POST) . PHP_EOL;
$requestUrl .= "<<<<<<<<<<GET>>>>>>>" . PHP_EOL . serialize($_GET) . PHP_EOL;
file_put_contents('./0.log', $requestUrl . PHP_EOL, FILE_APPEND );
注意:對0.log這個檔案要有可寫的權限