1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
public function file_get_contents_via_proxy( $sURL, $sProxyAddress, $iProxyPort, $sProxyUsername, $sProxyPassword )
{
$rcURLhandle = curl_init($sURL);
curl_setopt($rcURLhandle, CURLOPT_HEADER, 0);
curl_setopt($rcURLhandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($rcURLhandle, CURLOPT_BINARYTRANSFER,1);
curl_setopt($rcURLhandle, CURLOPT_FOLLOWLOCATION, true);
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 ;
}
$url = 'http://chart.apis.google.com/chart?chs=500x50&chf=bg,s,ffffff&cht=ls&chd=t:23.52,20.58,&chco=0066ff';
$contents = $this->file_get_contents_via_proxy($url, 'monproxy', 8080, Mondomaine\monid, monpassword);
file_put_contents($name.'.png', $contents); |
Partager