Jin*_*iel 4 php proxy file-get-contents
我从网站上获取我的应用程序数据,比如说x.com.我使用php函数file_get_contents()来获取数据.可以肯定的是,我的服务器的IP地址将显示在x.com的日志中.有没有办法隐藏我的服务器的IP而不使用代理?
如果我有代理,如何将其与file_get_contents()一起使用?
我需要在HTTP POST和HTTP GET方法中发送请求
far*_*992 21
test.php使用http://ifconfig.me/ip
代码修改自http://www.php.net/manual/en/function.file-get-contents.php
<?php
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n",
'proxy' => 'tcp://221.176.14.72:80',
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents('http://ifconfig.me/ip', false, $context);
var_dump($file);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24146 次 |
| 最近记录: |