PHP: 如何在服务器 ip 被阻止后使用 file_get_contents

PHP: How to use file_get_contents even after sever ip is blocked

我正在使用 file_get_contents('http://www.somewebsite.com') 函数,但我的服务器 IP 被永久阻止。有什么方法我仍然可以访问该网站吗?

是的。将 CURL 与匿名代理一起使用

$url = 'http://www.somewebsite.com';
$proxy = 'xxx.xxx.xxx.xxx:xxxx';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_page = curl_exec($ch);
curl_close($ch);