I've tested this and it should work to authorise the request for a local proxy:-
PHP Code:
<?php
/**
* Obtains remote data via a local proxy
* requiring authorisation.
*
* @param String $sURL The remote target
* @param String $sProxyAddress The FQDN or IP address of your local proxy
* @param Integer $iProxyPort The proxy servers port
* @param String $sProxyUsername Your domain username prefixed by your local domain name eg. DOMAIN\USERNAME
* @param String $sProxyPassword Your domain password
* @return String
*/
function file_get_contents_via_proxy( $sURL, $sProxyAddress, $iProxyPort, $sProxyUsername, $sProxyPassword )
{
$rcURLhandle = curl_init();
curl_setopt($rcURLhandle, CURLOPT_URL, $sURL);
curl_setopt($rcURLhandle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($rcURLhandle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($rcURLhandle, CURLOPT_PROXY, sprintf('%s:%s',$sProxyAddress,$iProxyPort));
curl_setopt($rcURLhandle, CURLOPT_PROXYUSERPWD, sprintf('%s:%s',$sProxyUsername,$sProxyPassword));
curl_setopt($rcURLhandle, CURLOPT_RETURNTRANSFER, true);
$sData = curl_exec($rcURLhandle);
return ( curl_errno($rcURLhandle) > 0 ) ? false : $sData ;
}
echo file_get_contents_via_proxy('http://www.google.co.uk/', '10.0.0.1', 8080, 'DOMAIN\USERNAME', 'PASSWORD');
?>
Bookmarks