我正在尝试设置一个使用curl的php项目,我的设置在代理后面。该脚本可以通过代理使用以下设置访问URL。
$url = 'http://dynupdate.no-ip.com/ip.php';
$proxy = '127.0.0.1:8888';
//$proxyauth = 'user:password';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
echo $curl_scraped_page;
但是因为我正在使用第三方脚本而且我不想修改该脚本; 我想知道是否有办法将cURL设置为默认情况下通过代理。有点像
$opts = array('http' => array('request_fulluri' => true,
'proxy' => 'tcp://10.0.9.61:3128'),
);
stream_context_get_default($opts);
适用于fopen或get_file_contents。
我查看了其他帖子,但没有找到任何内容。感谢您的帮助。