文章详情
接入指南 - 代码 - PHP - stream
// 要访问的目标页面
$targetUrl = "http://www.quqiquqi.com/test";
// 请求切换IP(仅短效版、长效版用。动态版每次请求自动切换,无需指定)
//$targetUrl = "http://www.quqiquqi.com/switch-ip";
// 查看当前隧道出口IP信息
//$targetUrl = "http://www.quqiquqi.com/current-ip";

// 代理服务器
$proxyServer = "tunnel.quqiquqi.com:8600";

// 隧道身份信息
$proxyUser   = "U123456789";
$proxyPass   = "P123456789";

$proxyAuth = base64_encode("{$proxyUser}:{$proxyPass}");

// 设置IP切换头(仅支持HTTP)
// 仅短效版、长效版用,动态版每次请求自动切换,无需指定。
$headers = implode("\r\n", [
    "Proxy-Authorization: Basic {$proxyAuth}",
    "Proxy-Switch-Ip: yes",
]);

$options = [
    "http" => [
        "proxy"  => $proxyServer,
        "header" => $headers,
        "method" => "GET",
    ],
];

$context = stream_context_create($options);

$result = file_get_contents($url, false, $context);

var_dump($result);              
        
发布时间:2021-10-02

在线客服