- /**
- * 请求
- *
- * @param [type] $targetUrl 目标站点
- * @param [type] $proxyIp 代理ip
- * @param [type] $proxyPort 代理端口
- * @param [type] $proxyUser AuthKey
- * @param [type] $proxyPassword AuthPwd
- * @return void
- */
- function sendRequest($targetUrl, $proxyIp, $proxyPort, $proxyUser, $proxyPassword){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $targetUrl);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_PROXYPORT, $proxyPort);
- curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
- curl_setopt($ch, CURLOPT_PROXY, $proxyIp);
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyUser . ':' . $proxyPassword);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- $data = sendRequest('https://ip.hahado.cn/api/index?ip=&type=0', '请改成您的代理IP', 端口号, '请改成您的Key', '请改成您的AuthPwd');
- var_dump($data);
直接嵌入使用,即可跑通隧道模式。
标签:ch,隧道,setopt,示例,param,curl,PHP,type,CURLOPT From: https://blog.51cto.com/u_15822686/7031001